- Type Parameters:
T- the value type
- All Superinterfaces:
Consumer<Set<T>>,EventObserver<Set<T>>,Iterable<T>,Supplier<Set<T>>,Value<Set<T>>,ValueObserver<Set<T>>,ValueSetObserver<T>
An observable wrapper for one or more values, including a possible null value.
A factory class for
ValueSet instances.-
Nested Class Summary
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 set, returns true if the set did not contain the value before adding.booleanaddAll(Collection<T> values) Adds the given values to this set, returns true unless the set already contained all the values.booleanAdds the given values to this set, returns true unless the set already contained all the values.voidclear()Clears all values from this ValueSet.observer()Returns aValueSetObservernotified each time this value changes.booleanRemoves a value from this set, returns true if the set contained the value before removing.booleanremoveAll(Collection<T> values) Removes the given values from this set, returns true if the set contained one or more of the values.booleanRemoves the given values from this set, returns true if the set contained one or more of the values.voidset(Collection<T> values) Sets the values.value()static <T> ValueSet<T>valueSet()Creates a new emptyValueSet, usingValue.Notify.WHEN_CHANGED.static <T> ValueSet<T>valueSet(Value.Notify notify) Creates a new emptyValueSetstatic <T> ValueSet<T>Creates a newValueSet, usingValue.Notify.WHEN_CHANGED.static <T> ValueSet<T>valueSet(Set<T> initialValues, Value.Notify notify) Creates a newValueSetMethods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, addWeakDataListener, addWeakListener, removeDataListener, removeListener, removeWeakDataListener, removeWeakListenerMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface is.codion.common.value.Value
accept, addValidator, link, link, map, mapNull, removeValidator, set, unlink, unlink, validateMethods inherited from interface is.codion.common.value.ValueObserver
isEqualTo, isNotEqualTo, isNotNull, isNull, nullable, optionalMethods inherited from interface is.codion.common.value.ValueSetObserver
contains, containsAll, empty, notEmpty, size
-
Method Details
-
set
Sets the values. Note that duplicates are quietly dropped.- Parameters:
values- the values to set
-
add
Adds a value to this set, returns true if the set did not contain the value before adding.- Parameters:
value- the value to add- Returns:
- true if the value was added
-
addAll
Adds the given values to this set, returns true unless the set already contained all the values.- Parameters:
values- the values to add- Returns:
- true if a value was added
-
addAll
Adds the given values to this set, returns true unless the set already contained all the values.- Parameters:
values- the values to add- Returns:
- true if a value was added
-
remove
Removes a value from this set, returns true if the set contained the value before removing.- Parameters:
value- the value to remove- Returns:
- true if the value was removed
-
removeAll
Removes the given values from this set, returns true if the set contained one or more of the values.- Parameters:
values- the values to remove- Returns:
- true if value was removed
-
removeAll
Removes the given values from this set, returns true if the set contained one or more of the values.- Parameters:
values- the values to remove- Returns:
- true if value was removed
-
clear
void clear()Clears all values from this ValueSet. -
value
Returns aValueinstance based on thisValueSet. Setting this value to null clears the value set. This value consistently returns the first value from the underlyingValueSetin case it contains multiple items.- Returns:
- a single item value based on this value set
-
observer
ValueSetObserver<T> observer()Returns aValueSetObservernotified each time this value changes.- Specified by:
observerin interfaceValue<T>- Returns:
- a
ValueSetObserverfor this value
-
valueSet
Creates a new emptyValueSet, usingValue.Notify.WHEN_CHANGED.- Type Parameters:
T- the value type- Returns:
- a new
ValueSet
-
valueSet
Creates a new emptyValueSet- Type Parameters:
T- the value type- Parameters:
notify- specifies when this value set notifies its listeners- Returns:
- a new
ValueSet
-
valueSet
Creates a newValueSet, usingValue.Notify.WHEN_CHANGED.- Type Parameters:
T- the value type- Parameters:
initialValues- the initial values, may not be null- Returns:
- a new
ValueSet
-
valueSet
Creates a newValueSet- Type Parameters:
T- the value type- Parameters:
initialValues- the initial values, may not be nullnotify- specifies when this value set notifies its listeners- Returns:
- a new
ValueSet
-