E - The type of valuepublic interface ImmutableValue<E> extends BaseValue<E>
BaseValue where any
modifications of the underlying value result in a new instance of an
ImmutableValue and/or the ValueContainer if the
ValueContainer too is immutable.
The basis for immutability is that once created, the value can not be
changed for any reason. Change requires a new instance to be created. As the
ImmutableValue always has a ValueContainer, it is
recommended that the owning ValueContainer too is immutable, unless
the ImmutableValue is being passed around for data processing. The
underlying value of an ImmutableValue may be itself mutable, however
utilizing any provided methods by any of the ImmutableValue classes
is recommended.
| Modifier and Type | Method and Description |
|---|---|
Value<E> |
asMutable()
Creates a mutable
Value for this ImmutableValue. |
ImmutableValue<E> |
transform(Function<E,E> function)
Retrieves the underlying value for this
ImmutableValue and
applies the given Function onto that value, after which, the
product is sent to a new ImmutableValue replacing this one. |
ImmutableValue<E> |
with(E value)
Creates a new
ImmutableValue with the given E typed
value, such that if the owning ValueContainer is immutable, the
ValueContainer too is recreated as a new instance with the new
ImmutableValue. |
ImmutableValue<E> with(E value)
ImmutableValue with the given E typed
value, such that if the owning ValueContainer is immutable, the
ValueContainer too is recreated as a new instance with the new
ImmutableValue.value - The value to replaceValueContainer, a new instance if it too is
immutableImmutableValue<E> transform(Function<E,E> function)
ImmutableValue and
applies the given Function onto that value, after which, the
product is sent to a new ImmutableValue replacing this one.
If the ValueContainer too is immutable, a new instance of
the ValueContainer may be created. If the ValueContainer
is mutable, the same instance of the ValueContainer is retained.
function - The function to apply onto the existing valueValueContainer, a new instance if it too is
immutableValue<E> asMutable()
Value for this ImmutableValue.