Package io.kojan.xml

Class Property<EnclosingType,EnclosingBean,NestedType>

java.lang.Object
io.kojan.xml.Property<EnclosingType,EnclosingBean,NestedType>
Type Parameters:
EnclosingType - data type of entity
EnclosingBean - type of bean associated with the entity
NestedType - data type of property value
Direct Known Subclasses:
Attribute, Relationship

public abstract class Property<EnclosingType,EnclosingBean,NestedType> extends Object
Property of data Entity. Serves as a common base class for built-in Attributes and Relationships, 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 Iterables over values and setters allow multiple calls to add multiple values.

  • Field Details

  • Constructor Details

  • Method Details

    • dump

      protected abstract void dump(XMLDumper dumper, NestedType value) throws XMLException
      Serializes the property into XML format, using given XMLDumper.
      Parameters:
      dumper - the sink to serialize data to
      value - 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 given XMLParser.
      Parameters:
      parser - the source to deserialize data from
      Returns:
      deserialized property value
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • getTag

      public 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,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
    • singleton

      static <T> Iterable<T> singleton(T t)