Module is.codion.common.core
Package is.codion.common.value
Interface ValueCollection<T,C extends Collection<T>>
- Type Parameters:
T
- the value typeC
- the collection type
- All Superinterfaces:
Iterable<T>
,Observable<C>
,ObservableValueCollection<T,
,C> Observer<C>
,Value<C>
public interface ValueCollection<T,C extends Collection<T>>
extends Value<C>, ObservableValueCollection<T,C>
An observable wrapper for one or more values.
All implementations are thread-safe and support concurrent access.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
ValueCollection.Builder<T,
C extends Collection<T>, B extends ValueCollection.Builder<T, C, B>> Builds aValueCollection
instance.Nested classes/interfaces inherited from interface is.codion.common.value.Value
Value.BuilderFactory, Value.Notify, Value.Validator<T>
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a value to thisValueCollection
instance.boolean
addAll
(Collection<T> values) Adds the given values to thisValueCollection
instance.boolean
Adds the given values to thisValueCollection
instance.get()
default boolean
If false then get() is guaranteed to never return null.Returns anObservableValueCollection
notified each time this value changes.boolean
Removes a single instance of the given value from thisValueCollection
instance.boolean
removeAll
(Collection<T> values) Removes the given values from thisValueCollection
instance.boolean
Removes the given values from thisValueCollection
instance.void
set
(@Nullable Collection<T> values) Sets the values.value()
Returns aValue
instance based on thisValueCollection
.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface is.codion.common.observer.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, getOrThrow, getOrThrow, isEqualTo, isNotEqualTo, isNull, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
Methods inherited from interface is.codion.common.value.ObservableValueCollection
contains, containsAll, isEmpty, size
-
Method Details
-
get
- Specified by:
get
in interfaceObservable<T>
- Specified by:
get
in interfaceObservableValueCollection<T,
C extends Collection<T>> - Returns:
- the value
-
isNullable
default boolean isNullable()Description copied from interface:Observable
If false then get() is guaranteed to never return null.- Specified by:
isNullable
in interfaceObservable<T>
- Returns:
- true if this observable can be null
-
set
Sets the values.- Parameters:
values
- the values to set
-
add
Adds a value to thisValueCollection
instance.- Parameters:
value
- the value to add- Returns:
- true if the value was added
- See Also:
-
addAll
Adds the given values to thisValueCollection
instance.- Parameters:
values
- the values to add- Returns:
- true if a value was added
- See Also:
-
addAll
Adds the given values to thisValueCollection
instance.- Parameters:
values
- the values to add- Returns:
- true if a value was added
- See Also:
-
remove
Removes a single instance of the given value from thisValueCollection
instance.- Parameters:
value
- the value to remove- Returns:
- true if the value was removed
- See Also:
-
removeAll
Removes the given values from thisValueCollection
instance.- Parameters:
values
- the values to remove- Returns:
- true if a value was removed
- See Also:
-
removeAll
Removes the given values from thisValueCollection
instance.- Parameters:
values
- the values to remove- Returns:
- true if a value was removed
- See Also:
-
value
Returns aValue
instance based on thisValueCollection
. Setting this value to null clears the values. This value consistently returns the first value from the underlyingValueCollection
in case it is sequenced and contains multiple items.- Returns:
- a single item value based on this values instance
-
observable
ObservableValueCollection<T,C> observable()Returns anObservableValueCollection
notified each time this value changes.- Specified by:
observable
in interfaceValue<T>
- Returns:
- an
ObservableValueCollection
for this value
-