Interface InheritedCollection<K,V>
-
- Type Parameters:
K
- The type of the key of the elements in this collection.V
- The type of the values of the elements in this collection.
public interface InheritedCollection<K,V>
This interface represents a collection that supports inheritance. That is, elements of this collection may be added, changed or removed in parent-child-relations. This collection keeps track of this which allows to store only the changes with respect to a parent collection.
All elements stored in this collection need to have a primary key, for instance, a UUID or a unique name. This allows to identify the element especially regarding the overriding (including removal of the element in child collections).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsKey(K key)
Gets whether this collection (or one of its parents) contains the designated key.V
get(K key)
Gets the value of the designated key ornull
in case this collection does not provide a value for this key.Map<K,V>
getAll()
Gets all elements of this collection (including the inherited ones), mapped from primary key to the corresponding value.Map<K,V>
getAllInherited()
Gets all elements of this collections that are inherited.Map<K,V>
getAllOwn()
Gets the elements of this collections that are specific to this collection and not inherited.V
getOrCreateOwn(K key)
Gets the value of the designated key (including the parent) which is not inherited or creates a new one in case this collection does not have a specific value for this key yet.boolean
hasParent(K key)
Gets whether the designated key has a parent, that is one of the parent collections contains this key.boolean
isInherited(K key)
Gets whether the element with the designated key is inherited.void
removeOwnValue(K key)
Removes the element with the designated key from this collection that overrides an element from a parent entity.void
set(K key, V element)
Sets or updates the designated element having the designated key.
-
-
-
Method Detail
-
getAll
Map<K,V> getAll()
Gets all elements of this collection (including the inherited ones), mapped from primary key to the corresponding value.- Returns:
- All elements of this collection (including the inherited ones) mapped from primary key to the corresponding value.
-
getAllOwn
Map<K,V> getAllOwn()
Gets the elements of this collections that are specific to this collection and not inherited. This also includes the removal of an inherited element, which is the corresponding key mapped tonull
as value.- Returns:
- The elements of this collections that are specific to this collection and not inherited.
-
getAllInherited
Map<K,V> getAllInherited()
Gets all elements of this collections that are inherited.- Returns:
- The elements of this collections that are inherited.
-
containsKey
boolean containsKey(K key)
Gets whether this collection (or one of its parents) contains the designated key.- Parameters:
key
- The key of which to get whether it is within this (or a parent) collection.- Returns:
- Whether this collection (or one of its parents) contains the designated key.
-
get
V get(K key)
Gets the value of the designated key ornull
in case this collection does not provide a value for this key.- Parameters:
key
- The key of which to retrieve the value of this collection.- Returns:
- The value for the designated key or
null
in case this collection does not provide a value for the key.
-
getOrCreateOwn
V getOrCreateOwn(K key)
Gets the value of the designated key (including the parent) which is not inherited or creates a new one in case this collection does not have a specific value for this key yet.- Parameters:
key
- The key of which to retrieve the value of this collection.- Returns:
- The value for the designated key (including its parent) which is not inherited or a new one in case this collection does not have a specific value for this key yet.
-
set
void set(K key, V element)
Sets or updates the designated element having the designated key. The element must not benull
! Removal of an element of a parent collection is not allowed.
The element is identified by the designated key, if the element also has the key as attribute, it will have to be ensured that it corresponds to the designated key. If this key already exists in this collection, the corresponding element will be updated, otherwise it will be added.- Parameters:
key
- The key of which to update or set the element.element
- The element which to set or update. This must not benull
.
-
isInherited
boolean isInherited(K key)
Gets whether the element with the designated key is inherited. Otherwise this collection explicitly provides a value (may benull
) for this key.- Parameters:
key
- The key which to check whether the corresponding value is inherited.- Returns:
- Whether the element with the designated key is inherited or set explicitly in this collection.
-
hasParent
boolean hasParent(K key)
Gets whether the designated key has a parent, that is one of the parent collections contains this key. Obviously, this is not the case if this collection has no parent.- Parameters:
key
- The key of which to get whether it has a parent.- Returns:
- Whether the designated key has a parent, that is one of the parent collections contains this key.
-
removeOwnValue
void removeOwnValue(K key)
Removes the element with the designated key from this collection that overrides an element from a parent entity. Afterwards the element is inherited again. This will also applies if the designated element is removed by this configuration description; this will be inherited completely afterwards.
Calling this method will have no effects if the element with the designated key is already inherited.- Parameters:
key
- The name which to remove the explicitly set value of and inherit its from the parent again. This must not be null.
-
-