Class TypeImpl
java.lang.Object
org.gcube.informationsystem.types.impl.TypeImpl
- All Implemented Interfaces:
Serializable,Element,IdentifiableElement,Type
- Direct Known Subclasses:
EntitySchemaImpl,PropertySchemaImpl,RelationSchemaImpl
The default implementation of the
Type interface.- Author:
- Luca Frosini (ISTI - CNR)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the type is abstract.Additional dynamic properties for future/extensible fields.The changelog of the type.The default changelog map.protected StringThe description of the type.The extended types, in declaration order.protected booleanWhether the type is final.protected booleanWhether the type definition is locked against modification and deletion.protected MetadataThe metadata of the type.protected StringThe name of the type.protected List<PropertyDefinition>The properties of the type, in declaration order.protected UUIDThe UUID of the type.protected VersionThe version of the type.Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, REDACTED, TYPE_PROPERTY, UNKNOWN_USERFields inherited from interface org.gcube.informationsystem.base.reference.IdentifiableElement
ID_PROPERTY, METADATA_PROPERTYFields inherited from interface org.gcube.informationsystem.types.reference.Type
ABSTRACT_PROPERTY, CHANGELOG_PROPERTY, DESCRIPTION_PROPERTY, EXTENDED_TYPES_PROPERTY, FINAL_PROPERTY, LOCKED_PROPERTY, NAME, NAME_PROPERTY, NAME_REGEX, PROPERTIES_PROPERTY, VERSION_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns theAccessTypeof this type definition.Returns the map of any additional, dynamic properties.Returns the changelog for this type.Gets the changelog with the version as a string.Returns the description of the type.Returns the types that this type extends.protected Class<?>getGenericClass(Type type) Gets the generic class of a type.getID()Returns the unique identifier (UUID) of the element.static TypegetInstance(Class<? extends Element> clz) Gets an instance of a type.Returns the metadata associated with the element.getName()Returns the name of the type.Gets the properties of the type.Returns the name of the element's type.Returns the version of the type.Gets the version as a string.booleanChecks if the type is abstract.booleanisFinal()Checks if the type is final.booleanisLocked()Checks whether this type's own definition is protected from modification and deletion through the Type write API.protected List<PropertyDefinition>retrieveListOfProperties(Class<?> clz) Retrieves the list of properties of a class.retrieveSuperClasses(Class<? extends E> type, Class<E> baseClass, String topSuperClass) Retrieves the super classes of a type.voidsetAdditionalProperty(String name, Object value) Sets an additional dynamic property.voidsetChangelog(Map<String, String> changelog) Sets the changelog from a map with the version as a string.voidsetExtendedTypes(List<String> extendedTypes) Sets the types that this type extends, preserving their declaration order.voidSets the unique identifier (UUID) for the element.voidsetLocked(boolean locked) Sets whether this type's own definition is protected from modification and deletion.voidsetMetadata(Metadata metadata) Sets the metadata for the element.voidsetVersion(String version) Sets the version from a string.
-
Field Details
-
DEFAULT_CHANGELOG_MAP
The default changelog map. -
uuid
The UUID of the type. -
metadata
The metadata of the type. -
name
The name of the type. -
description
The description of the type. -
version
The version of the type. -
changelog
The changelog of the type. -
abstractType
protected boolean abstractTypeWhether the type is abstract. -
finalClass
protected boolean finalClassWhether the type is final. -
locked
protected boolean lockedWhether the type definition is locked against modification and deletion. -
extendedTypes
The extended types, in declaration order. -
properties
The properties of the type, in declaration order. -
additionalProperties
Additional dynamic properties for future/extensible fields.
-
-
Constructor Details
-
TypeImpl
protected TypeImpl()Default constructor. -
TypeImpl
Constructs a new TypeImpl from a class.- Parameters:
clz- the class
-
-
Method Details
-
retrieveSuperClasses
protected <E extends Element> List<String> retrieveSuperClasses(Class<? extends E> type, Class<E> baseClass, String topSuperClass) Retrieves the super classes of a type.- Type Parameters:
E- the element type- Parameters:
type- the typebaseClass- the base classtopSuperClass- the top super class- Returns:
- the super classes, in declaration order
-
retrieveListOfProperties
Retrieves the list of properties of a class.- Parameters:
clz- the class- Returns:
- the properties, in declaration order
-
getGenericClass
Gets the generic class of a type.- Parameters:
type- the type- Returns:
- the generic class
-
getInstance
Gets an instance of a type.- Parameters:
clz- the class- Returns:
- the type instance
-
getID
Returns the unique identifier (UUID) of the element.- Specified by:
getIDin interfaceIdentifiableElement- Specified by:
getIDin interfaceType- Returns:
- The
UUIDof the element.
-
setID
Sets the unique identifier (UUID) for the element.- Specified by:
setIDin interfaceIdentifiableElement- Specified by:
setIDin interfaceType- Parameters:
uuid- TheUUIDto set.
-
getMetadata
Returns the metadata associated with the element.The metadata is included in JSON serialization only if it is not null.
- Specified by:
getMetadatain interfaceIdentifiableElement- Specified by:
getMetadatain interfaceType- Returns:
- The
Metadataof the element, ornullif none is set.
-
setMetadata
Sets the metadata for the element.- Specified by:
setMetadatain interfaceIdentifiableElement- Specified by:
setMetadatain interfaceType- Parameters:
metadata- TheMetadatato associate with the element.
-
getName
Returns the name of the type. -
getDescription
Returns the description of the type.- Specified by:
getDescriptionin interfaceType- Returns:
- The type description.
-
getVersion
Returns the version of the type.- Specified by:
getVersionin interfaceType- Returns:
- The type version.
-
getVersionAsString
Gets the version as a string.- Specified by:
getVersionAsStringin interfaceType- Returns:
- the version as a string
-
setVersion
Sets the version from a string.- Parameters:
version- the version as a string
-
getChangelog
Returns the changelog for this type.- Specified by:
getChangelogin interfaceType- Returns:
- A map of versions to change descriptions.
-
getChangelogWithVersionAsString
Gets the changelog with the version as a string.- Specified by:
getChangelogWithVersionAsStringin interfaceType- Returns:
- the changelog with the version as a string
-
setChangelog
Sets the changelog from a map with the version as a string.- Parameters:
changelog- the changelog with the version as a string
-
isAbstract
public boolean isAbstract()Checks if the type is abstract.- Specified by:
isAbstractin interfaceType- Returns:
trueif the type is abstract,falseotherwise.
-
isFinal
public boolean isFinal()Checks if the type is final. -
isLocked
public boolean isLocked()Checks whether this type's own definition is protected from modification and deletion through the Type write API.Server-assigned and never accepted from a client: a value submitted in a write payload is silently ignored, exactly as
metadataalready is, and the response reports the real value. It istrueexactly for the types intrinsic toinformation-system-modelitself, andfalsefor every other type, including those contributed by a domain model on the classpath. -
setLocked
public void setLocked(boolean locked) Sets whether this type's own definition is protected from modification and deletion. -
getExtendedTypes
Returns the types that this type extends.A
Listbecause the order carries meaning: it is the declaration order of the direct parents -- the local precedence order C3 linearization requires -- and it must survive serialization and persistence unchanged. ASetwould map to an unordered store and lose it.- Specified by:
getExtendedTypesin interfaceType- Returns:
- The parent type names, in declaration order.
-
setExtendedTypes
Sets the types that this type extends, preserving their declaration order.- Specified by:
setExtendedTypesin interfaceType- Parameters:
extendedTypes- the parent type names, in declaration order.
-
getProperties
Gets the properties of the type.- Specified by:
getPropertiesin interfaceType- Returns:
- the properties of the type
-
getAccessType
Returns theAccessTypeof this type definition.- Specified by:
getAccessTypein interfaceType- Returns:
- The access type.
-
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.
-
getAdditionalProperties
Returns the map of any additional, dynamic properties.- Specified by:
getAdditionalPropertiesin interfaceType- Returns:
- The map of additional properties.
-
setAdditionalProperty
Sets an additional dynamic property.- Specified by:
setAdditionalPropertyin interfaceType- Parameters:
name- the property namevalue- the property value
-