Class Property<EnclosingType,EnclosingBean,NestedType>
- java.lang.Object
-
- io.kojan.xml.Property<EnclosingType,EnclosingBean,NestedType>
-
- Type Parameters:
EnclosingType
- data type of entityEnclosingBean
- type of bean associated with the entityNestedType
- data type of property value
- Direct Known Subclasses:
Attribute
,Relationship
public abstract class Property<EnclosingType,EnclosingBean,NestedType> extends java.lang.Object
Property of dataEntity
. Serves as a common base class for built-inAttribute
s andRelationship
s, as well as other user-defined custom entity properties.An entity property is closely related to its corresponding bean property, understood as a pair of
Getter
andSetter
.A property can be optional, meaning that no instance of the property is required. If a property is not optional, then at least one instance of it is required for the entity to be valid.
A property can be unique, meaning that at most one instance of the property can be present. If the property is not unique, then more than one instance of the property is allowed.
Since non-unique properties allow multiple values, getters return
Iterable
s over values and setters allow multiple calls to add multiple values.- Author:
- Mikolaj Izdebski
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Property(java.lang.String tag, Getter<EnclosingType,java.lang.Iterable<NestedType>> getter, Setter<EnclosingBean,NestedType> setter, boolean optional, boolean unique)
Initializes the abstract property.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
dump(XMLDumper dumper, NestedType value)
Serializes the property into XML format, using givenXMLDumper
.Getter<EnclosingType,java.lang.Iterable<NestedType>>
getGetter()
Obtain property getter method that can be used to retrieve property value.Setter<EnclosingBean,NestedType>
getSetter()
Obtain property setter method that can be used to update property value.java.lang.String
getTag()
Determines XML element tag name used to serialize the property in XML form.boolean
isOptional()
Determines whether the property is optional or not.boolean
isUnique()
Determines whether the property is unique or not.protected abstract NestedType
parse(XMLParser parser)
Deserializes the property from XML format, using givenXMLParser
.
-
-
-
Constructor Detail
-
Property
protected Property(java.lang.String tag, Getter<EnclosingType,java.lang.Iterable<NestedType>> getter, Setter<EnclosingBean,NestedType> setter, boolean optional, boolean unique)
Initializes the abstract property.- Parameters:
tag
- XML element tag name used to serialize the property in XML form (seegetTag()
)getter
- property getter methodsetter
- property setter methodoptional
- whether the property is optional (seeisOptional()
)unique
- whether the property is unique (seeisUnique()
)
-
-
Method Detail
-
dump
protected abstract void dump(XMLDumper dumper, NestedType value) throws XMLException
Serializes the property into XML format, using givenXMLDumper
.- Parameters:
dumper
- the sink to serialize data tovalue
- property value to serialize- Throws:
XMLException
- in case exception occurs during XML serialization
-
parse
protected abstract NestedType parse(XMLParser parser) throws XMLException
Deserializes the property from XML format, using givenXMLParser
.- Parameters:
parser
- the source to deserialize data from- Returns:
- deserialized property value
- Throws:
XMLException
- in case exception occurs during XML deserialization
-
getTag
public java.lang.String getTag()
Determines XML element tag name used to serialize the property in XML form.- Returns:
- XML element tag name
-
isOptional
public boolean isOptional()
Determines whether the property is optional or not.A property can be optional, meaning that no instance of the property is required. If a property is not optional, then at least one instance of it is required for the entity to be valid.
- Returns:
true
iff the property is optional
-
isUnique
public boolean isUnique()
Determines whether the property is unique or not.A property can be unique, meaning that at most one instance of the property can be present. If the property is not unique, then more than one instance of the property is allowed.
- Returns:
true
iff the property is unique
-
getGetter
public Getter<EnclosingType,java.lang.Iterable<NestedType>> getGetter()
Obtain property getter method that can be used to retrieve property value.- Returns:
- property getter method
-
getSetter
public Setter<EnclosingBean,NestedType> getSetter()
Obtain property setter method that can be used to update property value.- Returns:
- property setter method
-
-