Interface ValueSet<T>

Type Parameters:
T - the value type
All Superinterfaces:
Consumer<Set<T>>, EventObserver<Set<T>>, Supplier<Set<T>>, Value<Set<T>>, ValueObserver<Set<T>>

public interface ValueSet<T> extends Value<Set<T>>
An observable wrapper for one or more values, including a possible null value. A factory class for ValueSet instances.
  • Method Details

    • set

      void set(Collection<T> values)
      Sets the values. Note that duplicates are quietly dropped.
      Parameters:
      values - the values to set
    • add

      boolean add(T value)
      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

      boolean addAll(T... values)
      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

      boolean remove(T value)
      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

      boolean removeAll(T... values)
      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

      Value<T> value()
      Returns a Value instance based on this ValueSet. Setting this value to null clears the value set. This value consistently returns the first value from the underlying ValueSet in case it contains multiple items.
      Returns:
      a single item value based on this value set
    • valueSet

      static <T> ValueSet<T> valueSet()
      Creates a new empty ValueSet, using Value.Notify.WHEN_CHANGED.
      Type Parameters:
      T - the value type
      Returns:
      a new ValueSet
    • valueSet

      static <T> ValueSet<T> valueSet(Value.Notify notify)
      Creates a new empty ValueSet
      Type Parameters:
      T - the value type
      Parameters:
      notify - specifies when this value set notifies its listeners
      Returns:
      a new ValueSet
    • valueSet

      static <T> ValueSet<T> valueSet(Set<T> initialValues)
      Creates a new ValueSet, using Value.Notify.WHEN_CHANGED.
      Type Parameters:
      T - the value type
      Parameters:
      initialValues - the initial values, may not be null
      Returns:
      a new ValueSet
    • valueSet

      static <T> ValueSet<T> valueSet(Set<T> initialValues, Value.Notify notify)
      Creates a new ValueSet
      Type Parameters:
      T - the value type
      Parameters:
      initialValues - the initial values, may not be null
      notify - specifies when this value set notifies its listeners
      Returns:
      a new ValueSet