All Implemented Interfaces:
Serializable, Element, EntityElement, IdentifiableElement, SchemaMixedElement, Context

public class ContextImpl extends EntityElementImpl implements Context
The default implementation of the Context interface.
Author:
Luca Frosini (ISTI - CNR)
See Also:
  • Field Details

    • name

      protected String name
      The name of the context.
    • state

      protected String state
      The state of the context.
    • parent

      protected IsParentOf parent
      The parent of the context.
    • children

      protected List<IsParentOf> children
      The children of the context.
    • additionalProperties

      protected Map<String,Object> additionalProperties
      Additional properties of the context.
    • allowedAdditionalKeys

      protected final Set<String> allowedAdditionalKeys
      A set of keys that are allowed as additional properties, even if they start with '_' or '@'.
  • Constructor Details

    • ContextImpl

      protected ContextImpl()
      Default constructor.
    • ContextImpl

      public ContextImpl(UUID uuid)
      Constructs a new context with a given UUID.
      Parameters:
      uuid - The UUID.
    • ContextImpl

      public ContextImpl(String name)
      Constructs a new context with a given name.
      Parameters:
      name - The name.
    • ContextImpl

      public ContextImpl(String name, UUID uuid)
      Constructs a new context with a given name and UUID.
      Parameters:
      name - The name.
      uuid - The UUID.
  • Method Details

    • getName

      public String getName()
      Returns the name of the context.
      Specified by:
      getName in interface Context
      Returns:
      The context name.
    • setName

      public void setName(String name)
      Sets the name of the context.
      Specified by:
      setName in interface Context
      Parameters:
      name - The name to set.
    • getState

      public String getState()
      Returns the current state of the context as a string.
      Specified by:
      getState in interface Context
      Returns:
      The context state.
      See Also:
    • setState

      public void setState(String state)
      Sets the state of the context.
      Specified by:
      setState in interface Context
      Parameters:
      state - The state to set.
    • getParent

      public IsParentOf getParent()
      Returns the parent of this context.
      Specified by:
      getParent in interface Context
      Returns:
      The IsParentOf relation to the parent, or null if this is a root context.
    • setParent

      public void setParent(UUID uuid)
      Sets the parent of this context by its UUID.
      Specified by:
      setParent in interface Context
      Parameters:
      uuid - The UUID of the parent context.
    • setParent

      public void setParent(Context context)
      Sets the parent of this context.
      Specified by:
      setParent in interface Context
      Parameters:
      context - The parent context.
    • setParentFromJson

      protected void setParentFromJson(IsParentOf isParentOf) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      Sets the parent from a JSON-deserialized IsParentOf object.
      Parameters:
      isParentOf - The deserialized parent relationship.
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during processing.
    • setParent

      public void setParent(IsParentOf isParentOf)
      Sets the parent of this context via an IsParentOf relation.
      Specified by:
      setParent in interface Context
      Parameters:
      isParentOf - The relation to the parent.
    • getChildren

      public List<IsParentOf> getChildren()
      Returns the children of this context.
      Specified by:
      getChildren in interface Context
      Returns:
      A list of IsParentOf relations to the children.
    • setChildrenFromJson

      protected void setChildrenFromJson(List<IsParentOf> children) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      Sets the children from a JSON-deserialized list of IsParentOf objects.
      Parameters:
      children - The list of deserialized child relationships.
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during processing.
    • addChildFromJson

      protected void addChildFromJson(IsParentOf isParentOf) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      Adds a child from a JSON-deserialized IsParentOf object.
      Parameters:
      isParentOf - The deserialized child relationship.
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonProcessingException - if an error occurs during processing.
    • addChild

      public void addChild(UUID uuid)
      Adds a child to this context by its UUID.
      Specified by:
      addChild in interface Context
      Parameters:
      uuid - The UUID of the child context.
    • addChild

      public void addChild(Context child)
      Adds a child to this context.
      Specified by:
      addChild in interface Context
      Parameters:
      child - The child context.
    • addChild

      public void addChild(IsParentOf isParentOf)
      Adds a child to this context via an IsParentOf relation.
      Specified by:
      addChild in interface Context
      Parameters:
      isParentOf - The relation to the child.
    • getAdditionalProperties

      public Map<String,Object> getAdditionalProperties()
      Returns a map of all additional properties not defined in the schema.
      Specified by:
      getAdditionalProperties in interface Context
      Specified by:
      getAdditionalProperties in interface SchemaMixedElement
      Returns:
      A Map containing the additional properties, where the key is the property name and the value is the property value.
    • setAdditionalProperties

      public void setAdditionalProperties(Map<String,Object> additionalProperties)
      Sets the map of additional properties for the element.
      Specified by:
      setAdditionalProperties in interface Context
      Specified by:
      setAdditionalProperties in interface SchemaMixedElement
      Parameters:
      additionalProperties - A Map of additional properties.
    • getAdditionalProperty

      public Object getAdditionalProperty(String key)
      Retrieves a single additional property by its key.
      Specified by:
      getAdditionalProperty in interface Context
      Specified by:
      getAdditionalProperty in interface SchemaMixedElement
      Parameters:
      key - The name of the additional property to retrieve.
      Returns:
      The value of the property, or null if the key is not found.
    • setAdditionalProperty

      public void setAdditionalProperty(String key, Object value)
      Sets a single additional property.
      Specified by:
      setAdditionalProperty in interface Context
      Specified by:
      setAdditionalProperty in interface SchemaMixedElement
      Parameters:
      key - The name of the additional property.
      value - The value of the additional property.