Class ImmutableClassList

All Implemented Interfaces:
ClassList, Serializable, Iterable<String>, Collection<String>, Set<String>

public class ImmutableClassList extends AbstractSet<String> implements ClassList, Serializable
Immutable class list implementation.

For internal use only. May be renamed or removed in a future release.

Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • ImmutableClassList

      public ImmutableClassList(Collection<String> values)
      Creates a new immutable class list with the given values.
      Parameters:
      values - the values of the class list
  • Method Details

    • add

      public boolean add(String e)
      Specified by:
      add in interface Collection<String>
      Specified by:
      add in interface Set<String>
      Overrides:
      add in class AbstractCollection<String>
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Collection<String>
      Specified by:
      iterator in interface Iterable<String>
      Specified by:
      iterator in interface Set<String>
      Specified by:
      iterator in class AbstractCollection<String>
    • size

      public int size()
      Specified by:
      size in interface Collection<String>
      Specified by:
      size in interface Set<String>
      Specified by:
      size in class AbstractCollection<String>
    • bind

      public SignalBinding<Boolean> bind(String name, Signal<Boolean> signal)
      Binds the presence of the given class name to the provided signal. The class name is immediately added or removed based on the current signal value when the binding is created. The class is added when the signal value is true and removed when the value is false.

      After the initial application, the binding is kept synchronized with any subsequent signal value changes while the owning Element is in attached state. While a binding for the given class name is active, manual calls to Set.add(Object), Set.remove(Object) or ClassList.set(String, boolean) for that name will throw a BindingActiveException. When the element is in detached state, signal value changes have no effect.

      Bulk operations that indiscriminately replace or clear the class list (for example Set.clear() or setting the class attribute via Element.setAttribute(String, String)) throw a BindingActiveException if any binding is active.

      Text nodes do not support binding a Signal to a stylesheet class, because they do not support styling in general.

      Specified by:
      bind in interface ClassList
      Parameters:
      name - the class name to bind, not null or blank
      signal - the boolean signal to bind to, not null
    • bind

      public SignalBinding<List<String>> bind(Signal<List<String>> names)
      Binds the class names to the provided signal. The class list is immediately updated to match the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes while the element is attached. Only one group binding is allowed per class list.

      The group binding coexists with static values and individual toggle bindings. Names that appear in both sources are deduplicated by the underlying classList (Set behavior).

      Null or empty entries in the list and a null list value are silently ignored.

      Bulk operations that indiscriminately replace or clear the class list (for example Set.clear() or setting the class attribute via Element.setAttribute(String, String)) throw a BindingActiveException if any binding is active.

      Text nodes do not support binding a Signal to stylesheet classes, because they do not support styling in general.

      Specified by:
      bind in interface ClassList
      Parameters:
      names - the signal providing the list of class names, not null