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 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 oneEntitytype to another. A complexPropertywith 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
Constructors Constructor Description Relationship(Entity<RelatedType,RelatedBean> relatedEntity, Getter<EnclosingType,java.lang.Iterable<RelatedType>> getter, Setter<EnclosingBean,RelatedType> setter, boolean optional, boolean unique)Creates a relationship between two entities.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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,java.lang.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 RelatedTypeparse(XMLParser parser)Deserializes the property from XML format, using givenXMLParser.
-
-
-
Constructor Detail
-
Relationship
public Relationship(Entity<RelatedType,RelatedBean> relatedEntity, Getter<EnclosingType,java.lang.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 Detail
-
of
public static <Type,Bean,RelatedType,RelatedBean> Relationship<Type,Bean,RelatedType,RelatedBean> of(Entity<RelatedType,RelatedBean> relatedEntity, Getter<Type,java.lang.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
protected void dump(XMLDumper dumper, RelatedType value) throws XMLException
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
protected RelatedType parse(XMLParser parser) throws XMLException
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
-
-