Class TypeImpl

    • 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.
      • changelog

        protected Map<Version,​String> changelog
        The changelog 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.
      • extendedTypes

        protected List<String> extendedTypes
        The extended types, in declaration order.
      • additionalProperties

        protected Map<String,​Object> additionalProperties
        Additional dynamic properties for future/extensible fields.
    • Constructor Detail

      • TypeImpl

        protected TypeImpl()
        Default constructor.
      • TypeImpl

        protected TypeImpl​(Class<? extends Element> clz)
        Constructs a new TypeImpl from a class.
        Parameters:
        clz - the class
    • 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 type
        baseClass - the base class
        topSuperClass - 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:
        getID in interface IdentifiableElement
        Specified by:
        getID in interface Type
        Returns:
        The UUID of the element.
      • setID

        public void setID​(UUID uuid)
        Sets the unique identifier (UUID) for the element.
        Specified by:
        setID in interface IdentifiableElement
        Specified by:
        setID in interface Type
        Parameters:
        uuid - The UUID to 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:
        getMetadata in interface IdentifiableElement
        Specified by:
        getMetadata in interface Type
        Returns:
        The Metadata of the element, or null if none is set.
      • getName

        public String getName()
        Returns the name of the type.
        Specified by:
        getName in interface Type
        Returns:
        The type name.
      • getDescription

        public String getDescription()
        Returns the description of the type.
        Specified by:
        getDescription in interface Type
        Returns:
        The type description.
      • getVersion

        public Version getVersion()
        Returns the version of the type.
        Specified by:
        getVersion in interface Type
        Returns:
        The type version.
      • getVersionAsString

        public String getVersionAsString()
        Gets the version as a string.
        Specified by:
        getVersionAsString in interface Type
        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:
        getChangelog in interface Type
        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:
        getChangelogWithVersionAsString in interface Type
        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:
        isAbstract in interface Type
        Returns:
        true if the type is abstract, false otherwise.
      • isFinal

        public boolean isFinal()
        Checks if the type is final.
        Specified by:
        isFinal in interface Type
        Returns:
        true if the type is final, false otherwise.
      • 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 metadata already is, and the response reports the real value. It is true exactly for the types intrinsic to information-system-model itself, and false for every other type, including those contributed by a domain model on the classpath.

        Specified by:
        isLocked in interface Type
        Returns:
        true if the type definition is locked, false otherwise.
      • setLocked

        public void setLocked​(boolean locked)
        Sets whether this type's own definition is protected from modification and deletion.
        Specified by:
        setLocked in interface Type
        Parameters:
        locked - true to mark the type definition as locked, false otherwise.
      • getExtendedTypes

        public List<String> getExtendedTypes()
        Returns the types that this type extends.

        A List because 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. A Set would map to an unordered store and lose it.

        Specified by:
        getExtendedTypes in interface Type
        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:
        setExtendedTypes in interface Type
        Parameters:
        extendedTypes - the parent type names, in declaration order.
      • 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.
      • getAdditionalProperties

        public Map<String,​Object> getAdditionalProperties()
        Returns the map of any additional, dynamic properties.
        Specified by:
        getAdditionalProperties in interface Type
        Returns:
        The map of additional properties.
      • setAdditionalProperty

        public void setAdditionalProperty​(String name,
                                          Object value)
        Sets an additional dynamic property.
        Specified by:
        setAdditionalProperty in interface Type
        Parameters:
        name - the property name
        value - the property value