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 thePropertyDefinitioninterface.- Author:
- Luca Frosini (ISTI - CNR)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringURI_REGEXThe regex for URIs.static StringURL_REGEXThe regex for URLs.static StringUUID_REGEXThe regex for UUIDs.-
Fields inherited from interface org.gcube.informationsystem.base.reference.Attribute
DEFAULT_VALUE_PROPERTY, DESCRIPTION_PROPERTY, MAX_PROPERTY, MIN_PROPERTY, NAME_PROPERTY, PROPERTY_TYPE_PROPERTY, REGEX_PROPERTY
-
Fields inherited from interface org.gcube.informationsystem.base.reference.AttributeDefinition
MANDATORY_PROPERTY, NOT_NULL_PROPERTY
-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, TYPE_PROPERTY
-
Fields inherited from interface org.gcube.informationsystem.types.reference.properties.PropertyDefinition
NAME, READ_ONLY_PROPERTY, VERSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPropertyDefinitionImpl()Default constructor.PropertyDefinitionImpl(ISProperty propertyAnnotation, Method method)Constructs a new PropertyDefinitionImpl from an annotation and a method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcompareIntegers(Integer thisInt, Integer otherInt)Compares two integers.intcompareTo(PropertyDefinition other)booleanequals(Object obj)ObjectgetDefaultValue()Returns the default value of the attribute.StringgetDescription()Returns the description of the attribute.IntegergetMax()Returns the maximum allowed value for the attribute.IntegergetMin()Returns the minimum allowed value for the attribute.StringgetName()Returns the name of the attribute.StringgetPropertyType()Returns the property type of the attribute as a string.PropertyTypeNamegetPropertyTypeName()Gets the property type name.StringgetRegexp()Returns the regular expression used to validate the attribute's value.StringgetTypeName()Returns the name of the element's type.inthashCode()booleanisMandatory()Checks if the attribute is mandatory.booleanisNotnull()Checks if the attribute's value cannot be null.booleanisReadonly()Checks if the property is read-only.voidsetDefaultValue(Object defaultValue)Sets the default value of the attribute.voidsetDescription(String description)Sets the description of the attribute.voidsetMandatory(boolean mandatory)Sets whether the attribute is mandatory.voidsetMax(Integer max)Sets the maximum allowed value for the attribute.voidsetMin(Integer min)Sets the minimum allowed value for the attribute.voidsetName(String name)Sets the name of the attribute.voidsetNotnull(boolean notnull)Sets whether the attribute's value can be null.voidsetPropertyType(String type)Sets the property type.voidsetReadonly(boolean readonly)Sets whether the property is read-only.voidsetRegexp(String regexp)Sets the regular expression for validating the attribute's value.StringtoString()
-
-
-
Field Detail
-
UUID_REGEX
public static final String UUID_REGEX
The regex for UUIDs.- See Also:
- Constant Field Values
-
URI_REGEX
public static final String URI_REGEX
The regex for URIs.
-
URL_REGEX
public static final String URL_REGEX
The regex for URLs.
-
-
Constructor Detail
-
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 annotationmethod- the method
-
-
Method Detail
-
getName
public String getName()
Returns the name of the attribute.- Specified by:
getNamein interfaceAttribute- Specified by:
getNamein interfacePropertyDefinition- Returns:
- The attribute's name.
-
setName
public void setName(String name)
Sets the name of the attribute.
-
getDescription
public String getDescription()
Returns the description of the attribute.- Specified by:
getDescriptionin interfaceAttribute- Specified by:
getDescriptionin interfacePropertyDefinition- Returns:
- The attribute's description.
-
setDescription
public void setDescription(String description)
Sets the description of the attribute.- Specified by:
setDescriptionin interfaceAttribute- Parameters:
description- The description to set.
-
isMandatory
public boolean isMandatory()
Checks if the attribute is mandatory.- Specified by:
isMandatoryin interfaceAttributeDefinition- Specified by:
isMandatoryin interfacePropertyDefinition- Returns:
trueif the attribute is mandatory,falseotherwise.
-
setMandatory
public void setMandatory(boolean mandatory)
Sets whether the attribute is mandatory.- Specified by:
setMandatoryin interfaceAttributeDefinition- Parameters:
mandatory-trueto make the attribute mandatory,falseotherwise.
-
isReadonly
public boolean isReadonly()
Checks if the property is read-only.- Specified by:
isReadonlyin interfacePropertyDefinition- Returns:
trueif the property is read-only,falseotherwise.
-
setReadonly
public void setReadonly(boolean readonly)
Sets whether the property is read-only.- Specified by:
setReadonlyin interfacePropertyDefinition- Parameters:
readonly-trueto make the property read-only.
-
isNotnull
public boolean isNotnull()
Checks if the attribute's value cannot be null.- Specified by:
isNotnullin interfaceAttributeDefinition- Specified by:
isNotnullin interfacePropertyDefinition- Returns:
trueif the attribute value must not be null,falseotherwise.
-
setNotnull
public void setNotnull(boolean notnull)
Sets whether the attribute's value can be null.- Specified by:
setNotnullin interfaceAttributeDefinition- Parameters:
notnull-trueto enforce a non-null value,falseotherwise.
-
getMax
public Integer getMax()
Returns the maximum allowed value for the attribute.- Specified by:
getMaxin interfaceAttribute- Specified by:
getMaxin interfacePropertyDefinition- Returns:
- The maximum value, or
nullif not set.
-
setMax
public void setMax(Integer max)
Sets the maximum allowed value for the attribute.
-
getMin
public Integer getMin()
Returns the minimum allowed value for the attribute.- Specified by:
getMinin interfaceAttribute- Specified by:
getMinin interfacePropertyDefinition- Returns:
- The minimum value, or
nullif not set.
-
setMin
public void setMin(Integer min)
Sets the minimum allowed value for the attribute.
-
getRegexp
public String getRegexp()
Returns the regular expression used to validate the attribute's value.- Specified by:
getRegexpin interfaceAttribute- Specified by:
getRegexpin interfacePropertyDefinition- Returns:
- The regular expression, or
nullif not set.
-
setRegexp
public void setRegexp(String regexp)
Sets the regular expression for validating the attribute's value.
-
getPropertyType
public String getPropertyType()
Returns the property type of the attribute as a string.- Specified by:
getPropertyTypein interfaceAttribute- Specified by:
getPropertyTypein interfacePropertyDefinition- Returns:
- The property type.
-
setPropertyType
public void setPropertyType(String type)
Sets the property type.- Specified by:
setPropertyTypein interfaceAttribute- Parameters:
type- the type
-
getPropertyTypeName
public PropertyTypeName getPropertyTypeName()
Gets the property type name.- Specified by:
getPropertyTypeNamein interfaceAttribute- Returns:
- the property type name
-
getDefaultValue
public Object getDefaultValue()
Returns the default value of the attribute.- Specified by:
getDefaultValuein interfaceAttribute- Specified by:
getDefaultValuein interfacePropertyDefinition- Returns:
- The default value.
-
setDefaultValue
public void setDefaultValue(Object defaultValue)
Sets the default value of the attribute.- Specified by:
setDefaultValuein interfaceAttribute- Parameters:
defaultValue- The default value to set.
-
compareIntegers
protected int compareIntegers(Integer thisInt, Integer otherInt)
Compares two integers.- Parameters:
thisInt- the first integerotherInt- the second integer- Returns:
- the result of the comparison
-
compareTo
public int compareTo(PropertyDefinition other)
- Specified by:
compareToin interfaceComparable<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:
getTypeNamein interfaceElement- Returns:
- The type name of the element.
-
-