- 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 TypeMethodDescriptionboolean
Adds a value to this set, returns true if the set did not contain the value before adding.boolean
addAll
(Collection<T> values) Adds the given values to this set, returns true unless the set already contained all the values.boolean
Adds the given values to this set, returns true unless the set already contained all the values.void
clear()
Clears all values from this ValueSet.observer()
Returns aValueSetObserver
notified each time this value changes.boolean
Removes a value from this set, returns true if the set contained the value before removing.boolean
removeAll
(Collection<T> values) Removes the given values from this set, returns true if the set contained one or more of the values.boolean
Removes the given values from this set, returns true if the set contained one or more of the values.void
set
(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 emptyValueSet
static <T> ValueSet<T>
Creates a newValueSet
, usingValue.Notify.WHEN_CHANGED
.static <T> ValueSet<T>
valueSet
(Set<T> initialValues, Value.Notify notify) Creates a newValueSet
Methods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, addWeakDataListener, addWeakListener, removeDataListener, removeListener, removeWeakDataListener, removeWeakListener
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface is.codion.common.value.Value
accept, addValidator, link, link, map, mapNull, removeValidator, set, unlink, unlink, validate
Methods inherited from interface is.codion.common.value.ValueObserver
isEqualTo, isNotEqualTo, isNotNull, isNull, nullable, optional
Methods 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 aValue
instance based on thisValueSet
. Setting this value to null clears the value set. This value consistently returns the first value from the underlyingValueSet
in case it contains multiple items.- Returns:
- a single item value based on this value set
-
observer
ValueSetObserver<T> observer()Returns aValueSetObserver
notified each time this value changes.- Specified by:
observer
in interfaceValue<T>
- Returns:
- a
ValueSetObserver
for 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
-