E - The type of elementC - The type of CollectionI - The extended ImmutableCollectionValue for self referencingM - The mutable CollectionValue counterpart for asMutable()public interface ImmutableCollectionValue<E,C extends Collection<E>,I extends ImmutableCollectionValue<E,C,I,M>,M extends CollectionValue<E,C,M,I>> extends ImmutableValue<C>
ImmutableValue type that handles a Collection of elements
type E. All of the methods provided for modification return new
instances of the same type. Likewise, the underlying ValueContainer
is not modified.| Modifier and Type | Method and Description |
|---|---|
M |
asMutable()
Creates a mutable
Value for this ImmutableValue. |
boolean |
contains(E element)
Checks if the given
E element is contained within the
backed Collection. |
boolean |
containsAll(Iterable<E> iterable)
Checks if all of the given elements in the provided
Iterable are
contained within the backed Collection. |
C |
getAll()
Creates a new
Collection of the proper type C with
all elements copied to the new collection. |
boolean |
isEmpty()
Checks if the backed
Collection is empty. |
int |
size()
Gets the size of the underlying collection of elements.
|
I |
transform(Function<C,C> 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. |
I |
with(C collection)
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. |
I |
withAll(Iterable<E> elements)
Creates a new
ImmutableCollectionValue with the given elements
along with any pre-existing values within this value. |
I |
withElement(E elements)
Creates a new
ImmutableCollectionValue with the given values
along with any pre-existing values within this value. |
I |
without(E element)
Creates a new
ImmutableCollectionValue without the given
E element. |
I |
withoutAll(Iterable<E> elements)
Creates a new
ImmutableCollectionValue without the given
elements of the provided Iterable. |
I |
withoutAll(Predicate<E> predicate)
Creates a new
ImmutableCollectionValue with elements that
when the given Predicate is Predicate.test(Object) on
the element and true is returned, the element will remain in the
new ImmutableCollectionValue. |
int size()
boolean isEmpty()
Collection is empty.Collection.isEmpty()I with(C collection)
ImmutableValueImmutableValue 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.with in interface ImmutableValue<C extends Collection<E>>collection - The value to replaceValueContainer, a new instance if it too is
immutableI withElement(E elements)
ImmutableCollectionValue with the given values
along with any pre-existing values within this value.elements - The values to addI transform(Function<C,C> function)
ImmutableValueImmutableValue 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.
transform in interface ImmutableValue<C extends Collection<E>>function - The function to apply onto the existing valueValueContainer, a new instance if it too is
immutableI withAll(Iterable<E> elements)
ImmutableCollectionValue with the given elements
along with any pre-existing values within this value.elements - The elements to addCollection.addAll(Collection)I without(E element)
ImmutableCollectionValue without the given
E element.element - The element to excludeI withoutAll(Iterable<E> elements)
ImmutableCollectionValue without the given
elements of the provided Iterable.elements - The elements to excludeI withoutAll(Predicate<E> predicate)
ImmutableCollectionValue with elements that
when the given Predicate is Predicate.test(Object) on
the element and true is returned, the element will remain in the
new ImmutableCollectionValue.predicate - The predicte to applyboolean contains(E element)
E element is contained within the
backed Collection.element - The element to checkboolean containsAll(Iterable<E> iterable)
Iterable are
contained within the backed Collection.iterable - The iterable elementsC getAll()
Collection of the proper type C with
all elements copied to the new collection. Any modifications to the new
collection are not reflected to this ImmutableCollectionValue.
Likewise, no modifications to this ImmutableCollectionValue are
reflected to the returned Collection.M asMutable()
ImmutableValueValue for this ImmutableValue.asMutable in interface ImmutableValue<C extends Collection<E>>