Interface ThemeList

All Superinterfaces:
Collection<String>, Iterable<String>, Serializable, Set<String>
All Known Implementing Classes:
ThemeListImpl

public interface ThemeList extends Set<String>, Serializable
Representation of the theme names for an Element.
Since:
1.0
Author:
Vaadin Ltd
  • Method Details

    • add

      boolean add(String themeName)
      Adds the given theme name.

      Since the theme attribute value is space separated, a theme name cannot contain spaces. For backwards compatibility a space separated value is still accepted here and adds each theme name in it, but it logs a warning and may stop being supported in a future version, so add one theme name per call, or use HasTheme.addThemeNames(String...).

      No other operation interprets a value that way: Set.contains(Object), Set.remove(Object), Set.addAll(Collection) and the bind methods all treat the value they are given as a single theme name, so remove("badge success") does not undo add("badge success").

      Specified by:
      add in interface Collection<String>
      Specified by:
      add in interface Set<String>
      Parameters:
      themeName - the theme name to add, not null or blank
      Returns:
      true if the theme list was modified, false if all the given theme names were already present
      Since:
      25.3
    • set

      default boolean set(String themeName, boolean set)
      Sets or removes the given theme name, based on the set parameter.
      Parameters:
      themeName - the theme name to set or remove
      set - true to set the theme name, false to remove it
      Returns:
      true if the theme list was modified (theme name added or removed), false otherwise
    • bind

      default SignalBinding<Boolean> bind(String name, Signal<Boolean> signal)
      Binds the presence of the given theme name to the provided signal so that the theme name is added when the signal value is true and removed when the value is false.

      While a binding for the given theme name is active, manual calls to Set.add(Object), Set.remove(Object), set(String, boolean), Set.addAll(Collection), Set.retainAll(Collection) or Set.removeAll(Collection) for that name will throw a BindingActiveException. Bindings are lifecycle-aware and only active while the owning Element is in attached state; they are deactivated while the element is in detached state.

      Bulk operations that indiscriminately replace or clear the theme list (for example Set.clear() or setting the theme attribute via HasTheme.setThemeName(String)) throw a BindingActiveException if any binding is active.

      Parameters:
      name - the theme name to bind, not null or blank
      signal - the boolean signal to bind to, not null
      Throws:
      BindingActiveException - thrown when there is already an existing binding
      Since:
      25.1
    • bind

      default SignalBinding<List<String>> bind(Signal<List<String>> names)
      Binds the theme names to the provided signal so that the theme list is dynamically updated to match the signal's value. Only one group binding is allowed per theme list.

      The group binding coexists with static values and individual toggle bindings. Names that appear in both sources may appear as duplicates in the theme attribute.

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

      Bulk operations that indiscriminately replace or clear the theme list (for example Set.clear() or setting the theme attribute via HasTheme.setThemeName(String)) throw a BindingActiveException if any binding is active.

      Parameters:
      names - the signal providing the list of theme names, not null
      Throws:
      BindingActiveException - thrown when there is already an existing group binding
      Since:
      25.1