Package io.kojan.xml

Class Relationship<EnclosingType,EnclosingBean,RelatedType,RelatedBean>

java.lang.Object
io.kojan.xml.Property<EnclosingType,EnclosingBean,RelatedType>
io.kojan.xml.Relationship<EnclosingType,EnclosingBean,RelatedType,RelatedBean>
Type Parameters:
EnclosingType - data type of entity
EnclosingBean - type of bean associated with the entity
RelatedType - data type of related entity
RelatedBean - type of bean of related entity

public class Relationship<EnclosingType,EnclosingBean,RelatedType,RelatedBean> extends Property<EnclosingType,EnclosingBean,RelatedType>
Relationship of one Entity type to another. A complex Property with no simple text representation.

When stored in XML form, a relationship is represented by zero or more XML subtrees describing each of related entity instances.

  • Field Details

  • Constructor Details

  • Method Details

    • of

      public static <Type, Bean, RelatedType, RelatedBean> Relationship<Type,Bean,RelatedType,RelatedBean> of(Entity<RelatedType,RelatedBean> relatedEntity, Getter<Type,Iterable<RelatedType>> getter, Setter<Bean,RelatedType> setter)
      Creates a non-unique, optional relationship with another entity.
      Type Parameters:
      Type - data type of relating entity
      Bean - type of bean associated with the relating entity
      RelatedType - data type of related entity
      RelatedBean - type of bean of related entity
      Parameters:
      relatedEntity - related entity
      getter - entity bean getter method that returns value of the related entity
      setter - entity bean setter method that returns value of the related entity
      Returns:
      created relationship
    • ofSingular

      public static <Type, Bean, RelatedType, RelatedBean> Relationship<Type,Bean,RelatedType,RelatedBean> ofSingular(Entity<RelatedType,RelatedBean> relatedEntity, Getter<Type,RelatedType> getter, Setter<Bean,RelatedType> setter)
      Creates a unique, optional relationship with another entity.
      Type Parameters:
      Type - data type of relating entity
      Bean - type of bean associated with the relating entity
      RelatedType - data type of related entity
      RelatedBean - type of bean of related entity
      Parameters:
      relatedEntity - related entity
      getter - entity bean getter method that returns value of the related entity
      setter - entity bean setter method that returns value of the related entity
      Returns:
      created relationship
    • dump

      protected void dump(XMLDumper dumper, RelatedType value) throws XMLException
      Description copied from class: Property
      Serializes the property into XML format, using given XMLDumper.
      Specified by:
      dump in class Property<EnclosingType,EnclosingBean,RelatedType>
      Parameters:
      dumper - the sink to serialize data to
      value - property value to serialize
      Throws:
      XMLException - in case exception occurs during XML serialization
    • parse

      protected RelatedType parse(XMLParser parser) throws XMLException
      Description copied from class: Property
      Deserializes the property from XML format, using given XMLParser.
      Specified by:
      parse in class Property<EnclosingType,EnclosingBean,RelatedType>
      Parameters:
      parser - the source to deserialize data from
      Returns:
      deserialized property value
      Throws:
      XMLException - in case exception occurs during XML deserialization