- Type Parameters:
T
- the value type
- All Superinterfaces:
Consumer<Set<T>>
,EventObserver<Set<T>>
,Supplier<Set<T>>
,Value<Set<T>>
,ValueObserver<Set<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
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.boolean
empty()
boolean
notEmpty()
boolean
Removes a value from this set, returns true if the set contained the value before removing.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 is.codion.common.value.Value
accept, addValidator, link, link, map, mapNull, observer, removeValidator, set, unlink, unlink, validate
Methods inherited from interface is.codion.common.value.ValueObserver
equalTo, isNotNull, isNull, notEqualTo, nullable, optional
-
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
-
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
-
empty
boolean empty()- Returns:
- true if this value set is empty
-
notEmpty
boolean notEmpty()- Returns:
- true if this value set is not empty
-
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
-
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
-