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 entityEnclosingBean- type of bean associated with the entityRelatedType- data type of related entityRelatedBean- 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.
- Author:
- Mikolaj Izdebski
-
Constructor Summary
ConstructorsConstructorDescriptionRelationship(Entity<RelatedType, RelatedBean> relatedEntity, Getter<EnclosingType, Iterable<RelatedType>> getter, Setter<EnclosingBean, RelatedType> setter, boolean optional, boolean unique) Creates a relationship between two entities. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddump(XMLDumper dumper, RelatedType value) Serializes the property into XML format, using givenXMLDumper.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.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.protected RelatedTypeDeserializes the property from XML format, using givenXMLParser.
-
Constructor Details
-
Relationship
public Relationship(Entity<RelatedType, RelatedBean> relatedEntity, Getter<EnclosingType, Iterable<RelatedType>> getter, Setter<EnclosingBean, RelatedType> setter, boolean optional, boolean unique) Creates a relationship between two entities.- Parameters:
relatedEntity- entity that is related togetter- relationship getter methodsetter- relationship setter methodoptional- whether the relationship is optional (seeProperty.isOptional())unique- whether the relationship is unique (seeProperty.isUnique())
-
-
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 entityBean- type of bean associated with the relating entityRelatedType- data type of related entityRelatedBean- type of bean of related entity- Parameters:
relatedEntity- related entitygetter- entity bean getter method that returns value of the related entitysetter- 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 entityBean- type of bean associated with the relating entityRelatedType- data type of related entityRelatedBean- type of bean of related entity- Parameters:
relatedEntity- related entitygetter- entity bean getter method that returns value of the related entitysetter- entity bean setter method that returns value of the related entity- Returns:
- created relationship
-
dump
Description copied from class:PropertySerializes the property into XML format, using givenXMLDumper.- Specified by:
dumpin classProperty<EnclosingType, EnclosingBean, RelatedType>- Parameters:
dumper- the sink to serialize data tovalue- property value to serialize- Throws:
XMLException- in case exception occurs during XML serialization
-
parse
Description copied from class:PropertyDeserializes the property from XML format, using givenXMLParser.- Specified by:
parsein classProperty<EnclosingType, EnclosingBean, RelatedType>- Parameters:
parser- the source to deserialize data from- Returns:
- deserialized property value
- Throws:
XMLException- in case exception occurs during XML deserialization
-