Module is.codion.common.core
Package is.codion.common.value
Interface Values<T,C extends Collection<T>>
- Type Parameters:
T
- the value typeC
- the collection type
- All Superinterfaces:
Consumer<C>
,Iterable<T>
,Observer<C>
,Value<C>
,ValueObserver<C>
,ValuesObserver<T,
C>
An observable wrapper for one or more values, including a possible null value.
A factory for
Values
instances.- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Values.Builder<T,
C extends Collection<T>, B extends Values.Builder<T, C, B>> Builds aValues
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 this Values instance.boolean
addAll
(Collection<T> values) Adds the given values to this Values instance.boolean
Adds the given values to this Values instance.static <T,
C extends Collection<T>>
Values.Builder<T,C, ?> observer()
Returns aValuesObserver
notified each time this value changes.boolean
Removes a single instance of the given value from this Values instance.boolean
removeAll
(Collection<T> values) Removes the given values from this Values instance.boolean
Removes the given values from this Values instance.boolean
set
(Collection<T> values) Sets the values.value()
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface is.codion.common.observer.Observer
addConsumer, addListener, addWeakConsumer, addWeakListener, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
Methods inherited from interface is.codion.common.value.Value
accept, addValidator, clear, link, link, map, removeValidator, set, unlink, unlink, validate
Methods inherited from interface is.codion.common.value.ValueObserver
get, isEqualTo, isNotEqualTo, isNotNull, isNull, nullable, optional
Methods inherited from interface is.codion.common.value.ValuesObserver
contains, containsAll, empty, notEmpty, size
-
Method Details
-
set
Sets the values.- Parameters:
values
- the values to set- Returns:
- true if this
Values
instance changed
-
add
Adds a value to this Values instance.- Parameters:
value
- the value to add- Returns:
- true if the value was added
- See Also:
-
addAll
Adds the given values to this Values instance.- Parameters:
values
- the values to add- Returns:
- true if a value was added
- See Also:
-
addAll
Adds the given values to this Values 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 this Values instance.- Parameters:
value
- the value to remove- Returns:
- true if the value was removed
- See Also:
-
removeAll
Removes the given values from this Values instance.- Parameters:
values
- the values to remove- Returns:
- true if a value was removed
- See Also:
-
removeAll
Removes the given values from this Values instance.- Parameters:
values
- the values to remove- Returns:
- true if a value was removed
- See Also:
-
value
Returns aValue
instance based on thisValues
. Setting this value to null clears the values. This value consistently returns the first value from the underlyingValues
in case it is sequenced and contains multiple items.- Returns:
- a single item value based on this values instance
-
observer
ValuesObserver<T,C> observer()Returns aValuesObserver
notified each time this value changes.- Specified by:
observer
in interfaceValue<T>
- Returns:
- a
ValuesObserver
for this value
-
builder
static <T,C extends Collection<T>> Values.Builder<T,C, builder?> (Supplier<C> create, Function<C, C> unmodifiable) - Type Parameters:
T
- the value typeC
- the collection type- Parameters:
create
- creates an empty instance of the required collection typeunmodifiable
- returns an unmodifiable view of the given collection- Returns:
- a
Values.Builder
instance
-