Class TypeImpl
- java.lang.Object
-
- org.gcube.informationsystem.types.impl.TypeImpl
-
- All Implemented Interfaces:
Serializable,Element,IdentifiableElement,Type
- Direct Known Subclasses:
EntityTypeImpl,PropertyTypeImpl,RelationTypeImpl
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<Version,String>changelogThe changelog of the type.static Map<Version,String>DEFAULT_CHANGELOG_MAPThe default changelog map.protected StringdescriptionThe description of the type.protected Set<String>extendedTypesThe extended types.protected booleanfinalClassWhether the type is final.protected MetadatametadataThe metadata of the type.protected StringnameThe name of the type.protected Set<PropertyDefinition>propertiesThe properties of the type.protected UUIDuuidThe UUID of the type.protected VersionversionThe version of the type.-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, TYPE_PROPERTY
-
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, NAME, NAME_PROPERTY, 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<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.Set<String>getExtendedTypes()Returns the set of 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.Set<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.protected Set<PropertyDefinition>retrieveListOfProperties(Class<?> clz)Retrieves the list of properties of a class.protected <E extends Element>
Set<String>retrieveSuperClasses(Class<? extends E> type, Class<E> baseClass, String topSuperClass)Retrieves the super classes of a type.voidsetChangelog(Map<String,String> changelog)Sets the changelog from a map with the version as a string.voidsetID(UUID uuid)Sets the unique identifier (UUID) for the element.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.
-
properties
protected Set<PropertyDefinition> properties
The properties of the type.
-
-
Method Detail
-
retrieveSuperClasses
protected <E extends Element> Set<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 set of super classes
-
retrieveListOfProperties
protected Set<PropertyDefinition> retrieveListOfProperties(Class<?> clz)
Retrieves the list of properties of a class.- Parameters:
clz- the class- Returns:
- the set of properties
-
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.
-
getExtendedTypes
public Set<String> getExtendedTypes()
Returns the set of types that this type extends.- Specified by:
getExtendedTypesin interfaceType- Returns:
- A set of parent type names.
-
getProperties
public Set<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.
-
-