C - The type of container for fluencypublic interface ValueContainer<C extends ValueContainer<C>>
BaseValues. While
there exists a CompositeValueStore and ImmutableValueStore,
the emphasis of ValueContainer is that it only contains "data". It
is not known whether a ValueContainer is mutable or immutable.
Being that a ValueContainer is literally a container of
BaseValues, it itself does not contain the underlying values of
data. A ValueContainer may not always be parented by another
ValueContainer, such as the case for DataManipulators and
DataHolders, it is recommended to knowingly understand the
fundamental differences between them.
| Modifier and Type | Method and Description |
|---|---|
C |
copy()
Creates a clone copy of this
ValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance. |
<E> Optional<E> |
get(Key<? extends BaseValue<E>> key)
|
Set<Key<?>> |
getKeys()
Gets all applicable
Keys for this ValueContainer. |
default <E> E |
getOrElse(Key<? extends BaseValue<E>> key,
E defaultValue)
Attempts to get the underlying value if available.
|
default <E> E |
getOrNull(Key<? extends BaseValue<E>> key)
Attempts to get the underlying value if available and supported.
|
<E,V extends BaseValue<E>> |
getValue(Key<V> key)
|
Set<ImmutableValue<?>> |
getValues()
Gets all applicable
BaseValues associated with this
ValueContainer. |
default <E> E |
require(Key<? extends BaseValue<E>> key)
|
default boolean |
supports(BaseValue<?> baseValue)
Checks if the provided
BaseValue is supported. |
boolean |
supports(Key<?> key)
Checks if the given
Key is supported by this
ValueContainer. |
<E> Optional<E> get(Key<? extends BaseValue<E>> key)
BaseValue
linked to the provided Key. If the Key is not
supported, Optional.empty() is returned. It is important
to check for support of a Key by either calling
supports(BaseValue) or supports(Key).E - The type of valuekey - The key linking thedefault <E> E require(Key<? extends BaseValue<E>> key)
BaseValue
linked to the provided Key.
If the Key is not supported or
available, NoSuchElementException will be thrown.
E - The type of valuekey - The keyNoSuchElementException - If the value is not supported or present@Nullable default <E> E getOrNull(Key<? extends BaseValue<E>> key)
BaseValue is not supported whatsoever by this
ValueContainer, an exception is thrown.default <E> E getOrElse(Key<? extends BaseValue<E>> key, E defaultValue)
defaultValue is returned, if the
BaseValue is even supported.E - The type of valuekey - The key backing the BaseValuedefaultValue - The value to default to if not set<E,V extends BaseValue<E>> Optional<V> getValue(Key<V> key)
E - The type of the return typeV - The type of valuekey - The key linked to the BaseValueboolean supports(Key<?> key)
Key is supported by this
ValueContainer.key - The key to checkdefault boolean supports(BaseValue<?> baseValue)
BaseValue is supported.baseValue - The base value to checkC copy()
ValueContainer as a new
ValueContainer such that all the BaseValues are
safely duplicated to the new instance.Set<Key<?>> getKeys()
Keys for this ValueContainer.
Changes can not be made to the set to alter the ValueContainer,
nor can the BaseValues be changed with the provided
ImmutableSet.KeysSet<ImmutableValue<?>> getValues()
BaseValues associated with this
ValueContainer. As the data backed by the values are copied,
any modifications to the BaseValues will not be reflected onto
this ValueContainer.