Class 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
Entity
. Serves as a common base class for built-in Attribute
s
and Relationship
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
and Setter
.
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Getter
<EnclosingType, Iterable<NestedType>> private final boolean
private final Setter
<EnclosingBean, NestedType> private final String
private final boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Property
(String tag, Getter<EnclosingType, Iterable<NestedType>> getter, Setter<EnclosingBean, NestedType> setter, boolean optional, boolean unique) Initializes the abstract property. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
dump
(XMLDumper dumper, NestedType value) Serializes the property into XML format, using givenXMLDumper
.Obtain property getter method that can be used to retrieve property value.Obtain property setter method that can be used to update property value.getTag()
Determines XML element tag name used to serialize the property in XML form.boolean
Determines whether the property is optional or not.boolean
isUnique()
Determines whether the property is unique or not.protected abstract NestedType
Deserializes the property from XML format, using givenXMLParser
.(package private) static <T> Iterable
<T> singleton
(T t)
-
Field Details
-
tag
-
getter
-
setter
-
optional
private final boolean optional -
unique
private final boolean unique
-
-
Constructor Details
-
Property
protected Property(String tag, Getter<EnclosingType, 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 Details
-
dump
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
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
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
Obtain property getter method that can be used to retrieve property value.- Returns:
- property getter method
-
getSetter
Obtain property setter method that can be used to update property value.- Returns:
- property setter method
-
singleton
-