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 interfaceValueCollection.Builder<T,C extends Collection<T>, B extends ValueCollection.Builder<T, C, B>> Builds aValueCollectioninstance.Nested classes/interfaces inherited from interface is.codion.common.value.Value
Value.BuilderFactory, Value.Notify, Value.Validator<T> -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a value to thisValueCollectioninstance.booleanaddAll(Collection<T> values) Adds the given values to thisValueCollectioninstance.booleanAdds the given values to thisValueCollectioninstance.get()default booleanIf false then get() is guaranteed to never return null.Returns anObservableValueCollectionnotified each time this value changes.optional()booleanRemoves a single instance of the given value from thisValueCollectioninstance.booleanremoveAll(Collection<T> values) Removes the given values from thisValueCollectioninstance.booleanRemoves the given values from thisValueCollectioninstance.voidset(@Nullable Collection<T> values) Sets the values.value()Returns aValueinstance based on thisValueCollection.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface is.codion.common.observer.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, getOrThrow, getOrThrow, is, isNot, isNull, observer, removeConsumer, removeListener, removeWeakConsumer, removeWeakListenerMethods inherited from interface is.codion.common.value.ObservableValueCollection
contains, containsAll, isEmpty, size
-
Method Details
-
get
- Specified by:
getin interfaceObservable<T>- Specified by:
getin interfaceObservableValueCollection<T,C extends Collection<T>> - Returns:
- the value
-
isNullable
default boolean isNullable()Description copied from interface:ObservableIf false then get() is guaranteed to never return null.- Specified by:
isNullablein 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 thisValueCollectioninstance.- Parameters:
value- the value to add- Returns:
- true if the value was added
- See Also:
-
addAll
Adds the given values to thisValueCollectioninstance.- Parameters:
values- the values to add- Returns:
- true if a value was added
- See Also:
-
addAll
Adds the given values to thisValueCollectioninstance.- 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 thisValueCollectioninstance.- Parameters:
value- the value to remove- Returns:
- true if the value was removed
- See Also:
-
removeAll
Removes the given values from thisValueCollectioninstance.- Parameters:
values- the values to remove- Returns:
- true if a value was removed
- See Also:
-
removeAll
Removes the given values from thisValueCollectioninstance.- Parameters:
values- the values to remove- Returns:
- true if a value was removed
- See Also:
-
value
Returns aValueinstance based on thisValueCollection. Setting this value to null clears the values. This value consistently returns the first value from the underlyingValueCollectionin case it is sequenced and contains multiple items.- Returns:
- a single item value based on this
ValueCollectioninstance
-
optional
- Specified by:
optionalin interfaceObservable<T>- Specified by:
optionalin interfaceObservableValueCollection<T,C extends Collection<T>> - Returns:
- the values or an empty Optional if the collection is empty.
-
observable
ObservableValueCollection<T,C> observable()Returns anObservableValueCollectionnotified each time this value changes.- Specified by:
observablein interfaceValue<T>- Returns:
- an
ObservableValueCollectionfor this value
-