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>
-
Field Summary
Fields -
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 void
dump
(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 RelatedType
Deserializes the property from XML format, using givenXMLParser
.
-
Field Details
-
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, Relationship<Type,RelatedType, RelatedBean> Bean, ofRelatedType, RelatedBean> (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, Relationship<Type,RelatedType, RelatedBean> Bean, ofSingularRelatedType, RelatedBean> (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:Property
Serializes the property into XML format, using givenXMLDumper
.- Specified by:
dump
in 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:Property
Deserializes the property from XML format, using givenXMLParser
.- Specified by:
parse
in 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
-