Class EntityImpl

  • All Implemented Interfaces:
    Serializable, Element, EntityElement, IdentifiableElement, Entity, ERElement, ModelElement
    Direct Known Subclasses:
    FacetImpl, ResourceImpl

    public abstract class EntityImpl
    extends EntityElementImpl
    implements Entity
    The default abstract implementation of the Entity interface.

    Upon instantiation, a unique, non-reserved identifier (UUID) is automatically generated and assigned by default, purely as a convenience so that callers are not forced to set an id explicitly on every instance. This default does not by itself provide idempotency across retries (e.g. of a PUT): a caller that needs the server to recognize a retried request as the same logical instance must capture and reuse an explicit UUID via EntityElementImpl.setID(UUID) — a freshly constructed instance always receives a new random id.

    Author:
    Luca Frosini (ISTI - CNR)
    See Also:
    Serialized Form
    • Field Detail

      • supertypes

        protected List<String> supertypes
        The list of supertypes.
      • expectedType

        protected String expectedType
        The expected type.
      • contexts

        protected Map<UUID,​String> contexts
        The contexts in which the entity exists.
    • Constructor Detail

      • EntityImpl

        protected EntityImpl()
        Default constructor. Initializes the entity with an automatically generated, valid, and non-reserved UUID so that callers are not forced to set one explicitly. The identifier can be overridden using the setter, e.g. when the caller needs idempotency across retries.
    • Method Detail

      • getExpectedType

        public String getExpectedType()
        Returns the name of the expected type.

        This is used during deserialization to indicate the original type when a fallback to a supertype was necessary. It is included in JSON serialization only if it is not empty.

        Specified by:
        getExpectedType in interface ModelElement
        Returns:
        The expected type name.
      • getContexts

        public Map<UUID,​String> getContexts()
        Returns a map of contexts where this element is present.

        The map keys are the context UUIDs, and the values are the context names. This property is included in JSON serialization only if it is not null.

        Specified by:
        getContexts in interface ERElement
        Returns:
        A Map of context UUIDs to context names, or null.
      • setContexts

        protected void setContexts​(Map<UUID,​String> contexts)
        Sets the contexts in which the entity exists.
        Parameters:
        contexts - The contexts.