Class PropertyDefinitionImpl

java.lang.Object
org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl
All Implemented Interfaces:
Serializable, Comparable<PropertyDefinition>, Attribute, AttributeDefinition, Element, PropertyElement, PropertyDefinition

public final class PropertyDefinitionImpl extends Object implements PropertyDefinition
The default implementation of the PropertyDefinition interface.
Author:
Luca Frosini (ISTI - CNR)
See Also:
  • Constructor Details

    • PropertyDefinitionImpl

      protected PropertyDefinitionImpl()
      Default constructor.
    • PropertyDefinitionImpl

      public PropertyDefinitionImpl(ISProperty propertyAnnotation, Method method)
      Constructs a new PropertyDefinitionImpl from an annotation and a method.
      Parameters:
      propertyAnnotation - the annotation
      method - the method
      Throws:
      IllegalArgumentException - if the property takes a system field name on a getter other than the one of that field (see PropertyDefinition.SYSTEM_FIELD_GETTERS)
  • Method Details

    • getName

      public String getName()
      Returns the name of the attribute.
      Specified by:
      getName in interface Attribute
      Specified by:
      getName in interface PropertyDefinition
      Returns:
      The attribute's name.
    • setName

      public void setName(String name)
      Sets the name of the attribute.
      Specified by:
      setName in interface Attribute
      Parameters:
      name - The name to set.
    • getDescription

      public String getDescription()
      Returns the description of the attribute.
      Specified by:
      getDescription in interface Attribute
      Specified by:
      getDescription in interface PropertyDefinition
      Returns:
      The attribute's description.
    • setDescription

      public void setDescription(String description)
      Sets the description of the attribute.
      Specified by:
      setDescription in interface Attribute
      Parameters:
      description - The description to set.
    • isMandatory

      public boolean isMandatory()
      Checks if the attribute is mandatory.
      Specified by:
      isMandatory in interface AttributeDefinition
      Specified by:
      isMandatory in interface PropertyDefinition
      Returns:
      true if the attribute is mandatory, false otherwise.
    • setMandatory

      public void setMandatory(boolean mandatory)
      Sets whether the attribute is mandatory.
      Specified by:
      setMandatory in interface AttributeDefinition
      Parameters:
      mandatory - true to make the attribute mandatory, false otherwise.
    • isReadonly

      public boolean isReadonly()
      Checks if the property is read-only.
      Specified by:
      isReadonly in interface PropertyDefinition
      Returns:
      true if the property is read-only, false otherwise.
    • setReadonly

      public void setReadonly(boolean readonly)
      Sets whether the property is read-only.
      Specified by:
      setReadonly in interface PropertyDefinition
      Parameters:
      readonly - true to make the property read-only.
    • getMax

      public Number getMax()
      Returns the upper bound of the property value.

      A decimal number is admitted only when the base type of the property is Double or Float; for every other base type the bound is an integer.

      Specified by:
      getMax in interface Attribute
      Specified by:
      getMax in interface PropertyDefinition
      Returns:
      The upper bound, or null if not set.
    • setMax

      public void setMax(Number max)
      Sets the upper bound of the attribute.
      Specified by:
      setMax in interface Attribute
      Parameters:
      max - The upper bound to set, null for none.
    • getMin

      public Number getMin()
      Returns the lower bound of the property value.

      A decimal number is admitted only when the base type of the property is Double or Float; for every other base type the bound is an integer.

      Specified by:
      getMin in interface Attribute
      Specified by:
      getMin in interface PropertyDefinition
      Returns:
      The lower bound, or null if not set.
    • setMin

      public void setMin(Number min)
      Sets the lower bound of the attribute.
      Specified by:
      setMin in interface Attribute
      Parameters:
      min - The lower bound to set, null for none.
    • getRegexp

      public String getRegexp()
      Returns the regular expression used to validate the attribute's value.
      Specified by:
      getRegexp in interface Attribute
      Specified by:
      getRegexp in interface PropertyDefinition
      Returns:
      The regular expression, or null if not set.
    • setRegexp

      public void setRegexp(String regexp)
      Sets the regular expression for validating the attribute's value.
      Specified by:
      setRegexp in interface Attribute
      Parameters:
      regexp - The regular expression to set.
    • getPropertyType

      public String getPropertyType()
      Returns the property type of the attribute as a string.
      Specified by:
      getPropertyType in interface Attribute
      Specified by:
      getPropertyType in interface PropertyDefinition
      Returns:
      The property type.
    • setPropertyType

      public void setPropertyType(String type)
      Sets the property type.
      Specified by:
      setPropertyType in interface Attribute
      Parameters:
      type - the type
    • getPropertyTypeName

      public PropertyTypeName getPropertyTypeName()
      Gets the property type name.
      Specified by:
      getPropertyTypeName in interface Attribute
      Returns:
      the property type name
    • getDefaultValue

      public Object getDefaultValue()
      Returns the default value of the attribute.
      Specified by:
      getDefaultValue in interface Attribute
      Specified by:
      getDefaultValue in interface PropertyDefinition
      Returns:
      The default value.
    • setDefaultValue

      public void setDefaultValue(Object defaultValue)
      Sets the default value of the attribute.
      Specified by:
      setDefaultValue in interface Attribute
      Parameters:
      defaultValue - The default value to set.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareBounds

      protected int compareBounds(Number thisBound, Number otherBound)
      Compares two bounds by their decimal value, so that the same bound compares equal whatever Java type holds it (e.g. 1 and 1.0). An absent bound follows every present one.
      Parameters:
      thisBound - the first bound, null if absent
      otherBound - the second bound, null if absent
      Returns:
      the result of the comparison
    • compareTo

      public int compareTo(PropertyDefinition other)
      Specified by:
      compareTo in interface Comparable<PropertyDefinition>
    • getTypeName

      public String getTypeName()
      Returns the name of the element's type. This is typically used for type identification in serialized forms.
      Specified by:
      getTypeName in interface Element
      Returns:
      The type name of the element.