C
- The type of container for fluencypublic interface ValueContainer<C extends ValueContainer<C>>
BaseValue
s. 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
BaseValue
s, 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 DataManipulator
s and
DataHolder
s, 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 BaseValue s are
safely duplicated to the new instance. |
<E> Optional<E> |
get(Key<? extends BaseValue<E>> key)
|
Set<Key<?>> |
getKeys()
Gets all applicable
Key s 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
BaseValue s 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 BaseValue
defaultValue
- 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 BaseValue
boolean 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 BaseValue
s are
safely duplicated to the new instance.Set<Key<?>> getKeys()
Key
s for this ValueContainer
.
Changes can not be made to the set to alter the ValueContainer
,
nor can the BaseValue
s be changed with the provided
ImmutableSet
.Key
sSet<ImmutableValue<?>> getValues()
BaseValue
s associated with this
ValueContainer
. As the data backed by the values are copied,
any modifications to the BaseValue
s will not be reflected onto
this ValueContainer
.