Class ContextImpl
- java.lang.Object
-
- org.gcube.informationsystem.base.impl.ElementImpl
-
- org.gcube.informationsystem.base.impl.entities.EntityElementImpl
-
- org.gcube.informationsystem.contexts.impl.entities.ContextImpl
-
- All Implemented Interfaces:
Serializable,Element,EntityElement,IdentifiableElement,SchemaMixedElement,Context
public class ContextImpl extends EntityElementImpl implements Context
The default implementation of theContextinterface.- Author:
- Luca Frosini (ISTI - CNR)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>additionalPropertiesAdditional properties of the context.protected Set<String>allowedAdditionalKeysA set of keys that are allowed as additional properties, even if they start with '_' or '@'.protected List<IsParentOf>childrenThe children of the context.protected StringnameThe name of the context.protected IsParentOfparentThe parent of the context.protected StringstateThe state of the context.-
Fields inherited from class org.gcube.informationsystem.base.impl.entities.EntityElementImpl
metadata, uuid
-
Fields inherited from interface org.gcube.informationsystem.contexts.reference.entities.Context
CHILDREN_PROPERTY, NAME, NAME_PROPERTY, PARENT_PROPERTY, STATE
-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, NAME, TYPE_PROPERTY
-
Fields inherited from interface org.gcube.informationsystem.base.reference.entities.EntityElement
NAME
-
Fields inherited from interface org.gcube.informationsystem.base.reference.IdentifiableElement
ID_PROPERTY, METADATA_PROPERTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedContextImpl()Default constructor.ContextImpl(String name)Constructs a new context with a given name.ContextImpl(String name, UUID uuid)Constructs a new context with a given name and UUID.ContextImpl(UUID uuid)Constructs a new context with a given UUID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(UUID uuid)Adds a child to this context by its UUID.voidaddChild(Context child)Adds a child to this context.voidaddChild(IsParentOf isParentOf)Adds a child to this context via anIsParentOfrelation.protected voidaddChildFromJson(IsParentOf isParentOf)Adds a child from a JSON-deserializedIsParentOfobject.Map<String,Object>getAdditionalProperties()Returns a map of all additional properties not defined in the schema.ObjectgetAdditionalProperty(String key)Retrieves a single additional property by its key.List<IsParentOf>getChildren()Returns the children of this context.StringgetName()Returns the name of the context.IsParentOfgetParent()Returns the parent of this context.StringgetState()Returns the current state of the context as a string.voidsetAdditionalProperties(Map<String,Object> additionalProperties)Sets the map of additional properties for the element.voidsetAdditionalProperty(String key, Object value)Sets a single additional property.protected voidsetChildrenFromJson(List<IsParentOf> children)Sets the children from a JSON-deserialized list ofIsParentOfobjects.voidsetName(String name)Sets the name of the context.voidsetParent(UUID uuid)Sets the parent of this context by its UUID.voidsetParent(Context context)Sets the parent of this context.voidsetParent(IsParentOf isParentOf)Sets the parent of this context via anIsParentOfrelation.protected voidsetParentFromJson(IsParentOf isParentOf)Sets the parent from a JSON-deserializedIsParentOfobject.voidsetState(String state)Sets the state of the context.-
Methods inherited from class org.gcube.informationsystem.base.impl.entities.EntityElementImpl
getID, getMetadata, setID, setMetadata
-
Methods inherited from class org.gcube.informationsystem.base.impl.ElementImpl
getTypeName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.gcube.informationsystem.base.reference.Element
getTypeName
-
Methods inherited from interface org.gcube.informationsystem.base.reference.entities.EntityElement
getID, getMetadata, setID, setMetadata
-
-
-
-
Field Detail
-
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.
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
getName
public String getName()
Returns the name of the context.
-
setName
public void setName(String name)
Sets the name of the context.
-
getState
public String getState()
Returns the current state of the context as a string.- Specified by:
getStatein interfaceContext- Returns:
- The context state.
- See Also:
ContextState
-
setState
public void setState(String state)
Sets the state of the context.
-
getParent
public IsParentOf getParent()
Returns the parent of this context.- Specified by:
getParentin interfaceContext- Returns:
- The
IsParentOfrelation to the parent, ornullif this is a root context.
-
setParent
public void setParent(UUID uuid)
Sets the parent of this context by its UUID.
-
setParent
public void setParent(Context context)
Sets the parent of this context.
-
setParentFromJson
protected void setParentFromJson(IsParentOf isParentOf) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
Sets the parent from a JSON-deserializedIsParentOfobject.- 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 anIsParentOfrelation.
-
getChildren
public List<IsParentOf> getChildren()
Returns the children of this context.- Specified by:
getChildrenin interfaceContext- Returns:
- A list of
IsParentOfrelations 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 ofIsParentOfobjects.- 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-deserializedIsParentOfobject.- 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.
-
addChild
public void addChild(Context child)
Adds a child to this context.
-
addChild
public void addChild(IsParentOf isParentOf)
Adds a child to this context via anIsParentOfrelation.
-
getAdditionalProperties
public Map<String,Object> getAdditionalProperties()
Returns a map of all additional properties not defined in the schema.- Specified by:
getAdditionalPropertiesin interfaceContext- Specified by:
getAdditionalPropertiesin interfaceSchemaMixedElement- Returns:
- A
Mapcontaining 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:
setAdditionalPropertiesin interfaceContext- Specified by:
setAdditionalPropertiesin interfaceSchemaMixedElement- Parameters:
additionalProperties- AMapof additional properties.
-
getAdditionalProperty
public Object getAdditionalProperty(String key)
Retrieves a single additional property by its key.- Specified by:
getAdditionalPropertyin interfaceContext- Specified by:
getAdditionalPropertyin interfaceSchemaMixedElement- Parameters:
key- The name of the additional property to retrieve.- Returns:
- The value of the property, or
nullif the key is not found.
-
setAdditionalProperty
public void setAdditionalProperty(String key, Object value)
Sets a single additional property.- Specified by:
setAdditionalPropertyin interfaceContext- Specified by:
setAdditionalPropertyin interfaceSchemaMixedElement- Parameters:
key- The name of the additional property.value- The value of the additional property.
-
-