Class TypeImpl
- java.lang.Object
-
- org.gcube.informationsystem.types.impl.TypeImpl
-
- All Implemented Interfaces:
Serializable,Element,IdentifiableElement,Type
- Direct Known Subclasses:
EntitySchemaImpl,PropertySchemaImpl,RelationSchemaImpl
public class TypeImpl extends Object implements Type
The default implementation of theTypeinterface.- Author:
- Luca Frosini (ISTI - CNR)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanabstractTypeWhether the type is abstract.protected Map<String,Object>additionalPropertiesAdditional dynamic properties for future/extensible fields.protected Map<Version,String>changelogThe changelog of the type.static Map<Version,String>DEFAULT_CHANGELOG_MAPThe default changelog map.protected StringdescriptionThe description of the type.protected List<String>extendedTypesThe extended types, in declaration order.protected booleanfinalClassWhether the type is final.protected booleanlockedWhether the type definition is locked against modification and deletion.protected MetadatametadataThe metadata of the type.protected StringnameThe name of the type.protected List<PropertyDefinition>propertiesThe properties of the type, in declaration order.protected UUIDuuidThe UUID of the type.protected VersionversionThe version of the type.-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, REDACTED, TYPE_PROPERTY, UNKNOWN_USER
-
Fields inherited from interface org.gcube.informationsystem.base.reference.IdentifiableElement
ID_PROPERTY, METADATA_PROPERTY
-
Fields 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessTypegetAccessType()Returns theAccessTypeof this type definition.Map<String,Object>getAdditionalProperties()Returns the map of any additional, dynamic properties.Map<Version,String>getChangelog()Returns the changelog for this type.Map<String,String>getChangelogWithVersionAsString()Gets the changelog with the version as a string.StringgetDescription()Returns the description of the type.List<String>getExtendedTypes()Returns the types that this type extends.protected Class<?>getGenericClass(Type type)Gets the generic class of a type.UUIDgetID()Returns the unique identifier (UUID) of the element.static TypegetInstance(Class<? extends Element> clz)Gets an instance of a type.MetadatagetMetadata()Returns the metadata associated with the element.StringgetName()Returns the name of the type.List<PropertyDefinition>getProperties()Gets the properties of the type.StringgetTypeName()Returns the name of the element's type.VersiongetVersion()Returns the version of the type.StringgetVersionAsString()Gets the version as a string.booleanisAbstract()Checks 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.protected <E extends Element>
List<String>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.voidsetID(UUID uuid)Sets 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 Detail
-
DEFAULT_CHANGELOG_MAP
public static final Map<Version,String> DEFAULT_CHANGELOG_MAP
The default changelog map.
-
uuid
protected UUID uuid
The UUID of the type.
-
metadata
protected Metadata metadata
The metadata of the type.
-
name
protected String name
The name of the type.
-
description
protected String description
The description of the type.
-
version
protected Version version
The version of the type.
-
abstractType
protected boolean abstractType
Whether the type is abstract.
-
finalClass
protected boolean finalClass
Whether the type is final.
-
locked
protected boolean locked
Whether the type definition is locked against modification and deletion.
-
properties
protected List<PropertyDefinition> properties
The properties of the type, in declaration order.
-
-
Method Detail
-
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
protected List<PropertyDefinition> retrieveListOfProperties(Class<?> clz)
Retrieves the list of properties of a class.- Parameters:
clz- the class- Returns:
- the properties, in declaration order
-
getGenericClass
protected Class<?> getGenericClass(Type type)
Gets the generic class of a type.- Parameters:
type- the type- Returns:
- the generic class
-
getInstance
public static Type getInstance(Class<? extends Element> clz)
Gets an instance of a type.- Parameters:
clz- the class- Returns:
- the type instance
-
getID
public UUID getID()
Returns the unique identifier (UUID) of the element.- Specified by:
getIDin interfaceIdentifiableElement- Specified by:
getIDin interfaceType- Returns:
- The
UUIDof the element.
-
setID
public void setID(UUID uuid)
Sets the unique identifier (UUID) for the element.- Specified by:
setIDin interfaceIdentifiableElement- Specified by:
setIDin interfaceType- Parameters:
uuid- TheUUIDto set.
-
getMetadata
public Metadata 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
public void setMetadata(Metadata metadata)
Sets the metadata for the element.- Specified by:
setMetadatain interfaceIdentifiableElement- Specified by:
setMetadatain interfaceType- Parameters:
metadata- TheMetadatato associate with the element.
-
getName
public String getName()
Returns the name of the type.
-
getDescription
public String getDescription()
Returns the description of the type.- Specified by:
getDescriptionin interfaceType- Returns:
- The type description.
-
getVersion
public Version getVersion()
Returns the version of the type.- Specified by:
getVersionin interfaceType- Returns:
- The type version.
-
getVersionAsString
public String getVersionAsString()
Gets the version as a string.- Specified by:
getVersionAsStringin interfaceType- Returns:
- the version as a string
-
setVersion
public void setVersion(String version)
Sets the version from a string.- Parameters:
version- the version as a string
-
getChangelog
public Map<Version,String> getChangelog()
Returns the changelog for this type.- Specified by:
getChangelogin interfaceType- Returns:
- A map of versions to change descriptions.
-
getChangelogWithVersionAsString
public Map<String,String> getChangelogWithVersionAsString()
Gets the changelog with the version as a string.- Specified by:
getChangelogWithVersionAsStringin interfaceType- Returns:
- the changelog with the version as a string
-
setChangelog
public void setChangelog(Map<String,String> changelog)
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
public List<String> 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
public void setExtendedTypes(List<String> extendedTypes)
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
public List<PropertyDefinition> getProperties()
Gets the properties of the type.- Specified by:
getPropertiesin interfaceType- Returns:
- the properties of the type
-
getAccessType
public AccessType getAccessType()
Returns theAccessTypeof this type definition.- Specified by:
getAccessTypein interfaceType- Returns:
- The access type.
-
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.
-
getAdditionalProperties
public Map<String,Object> getAdditionalProperties()
Returns the map of any additional, dynamic properties.- Specified by:
getAdditionalPropertiesin interfaceType- Returns:
- The map of additional properties.
-
setAdditionalProperty
public void setAdditionalProperty(String name, Object value)
Sets an additional dynamic property.- Specified by:
setAdditionalPropertyin interfaceType- Parameters:
name- the property namevalue- the property value
-
-