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>,EventObserver<C>,Iterable<T>,Supplier<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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceValues.Builder<T,C extends Collection<T>, B extends Values.Builder<T, C, B>> Builds aValuesinstance.Nested classes/interfaces inherited from interface is.codion.common.value.Value
Value.Notify, Value.Validator<T> -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a value to this Values instance.booleanaddAll(Collection<T> values) Adds the given values to this Values instance.booleanAdds the given values to this Values instance.static <T,C extends Collection<T>>
Values.Builder<T,C, ?> observer()Returns aValuesObservernotified each time this value changes.booleanRemoves a single instance of the given value from this Values instance.booleanremoveAll(Collection<T> values) Removes the given values from this Values instance.booleanRemoves the given values from this Values instance.booleanset(Collection<T> values) Sets the values.value()Methods inherited from interface is.codion.common.event.EventObserver
addConsumer, addListener, addWeakConsumer, addWeakListener, removeConsumer, removeListener, removeWeakConsumer, removeWeakListenerMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface is.codion.common.value.Value
accept, addValidator, clear, link, link, map, removeValidator, set, unlink, unlink, validateMethods inherited from interface is.codion.common.value.ValueObserver
isEqualTo, isNotEqualTo, isNotNull, isNull, isNullable, optionalMethods 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
Valuesinstance 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 aValueinstance based on thisValues. Setting this value to null clears the values. This value consistently returns the first value from the underlyingValuesin case it is sequenced and contains multiple items.- Returns:
- a single item value based on this values instance
-
observer
ValuesObserver<T,C> observer()Returns aValuesObservernotified each time this value changes.- Specified by:
observerin interfaceValue<T>- Returns:
- a
ValuesObserverfor 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.Builderinstance
-