Class ThemeListImpl
- All Implemented Interfaces:
ThemeList,Serializable,Iterable<String>,Collection<String>,Set<String>
ThemeList that provides a live view
into the theme names of the corresponding element. Both reads and writes go
through the element attribute, THEME_ATTRIBUTE_NAME, so
that all instances obtained for the same element always agree on the current
theme names.
Since the attribute value is space separated, a theme name cannot contain
spaces. add(String) still accepts a space separated value for
backwards compatibility, adding each theme name in it and logging a warning,
but every other operation treats the value it is given as a single theme
name, so remove("badge success") does not undo
add("badge success").
The iterator returned by iterator() is the one exception to the live
view: it iterates the theme names present when it was created.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0.
- Author:
- Vaadin Ltd
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThemeListImpl(Element element) Creates new theme list for element specified. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the given theme name.booleanaddAll(Collection<? extends String> themeNames) Binds the theme names to the provided signal so that the theme list is dynamically updated to match the signal's value.Binds the presence of the given theme name to the provided signal so that the theme name is added when the signal value istrueand removed when the value isfalse.voidclear()booleanbooleancontainsAll(Collection<?> themeNames) booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> themeNamesToRemove) booleanretainAll(Collection<?> themeNamesToRetain) intsize()Object[]toArray()<T> T[]toArray(T[] a) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Field Details
-
THEME_ATTRIBUTE_NAME
- See Also:
-
-
Constructor Details
-
ThemeListImpl
Creates new theme list for element specified.- Parameters:
element- the element to reflect theme changes onto
-
-
Method Details
-
bind
Description copied from interface:ThemeListBinds the presence of the given theme name to the provided signal so that the theme name is added when the signal value istrueand removed when the value isfalse.While a binding for the given theme name is active, manual calls to
Set.add(Object),Set.remove(Object),ThemeList.set(String, boolean),Set.addAll(Collection),Set.retainAll(Collection)orSet.removeAll(Collection)for that name will throw aBindingActiveException. Bindings are lifecycle-aware and only active while the owningElementis 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 thethemeattribute viaHasTheme.setThemeName(String)) throw aBindingActiveExceptionif any binding is active. -
bind
Description copied from interface:ThemeListBinds 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
themeattribute.Null or empty entries in the list and a
nulllist value are silently ignored.Bulk operations that indiscriminately replace or clear the theme list (for example
Set.clear()or setting thethemeattribute viaHasTheme.setThemeName(String)) throw aBindingActiveExceptionif any binding is active. -
iterator
-
add
Adds the given theme name.Since the
themeattribute 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 useHasTheme.addThemeNames(String...).No other operation interprets a value that way:
Set.contains(Object),Set.remove(Object),Set.addAll(Collection)and thebindmethods all treat the value they are given as a single theme name, soremove("badge success")does not undoadd("badge success").A space separated value is split into the individual theme names, which are all added, and logs a warning. See
ThemeList.add(String).- Specified by:
addin interfaceCollection<String>- Specified by:
addin interfaceSet<String>- Specified by:
addin interfaceThemeList- Parameters:
themeName- the theme name to add, notnullor blank- Returns:
trueif the theme list was modified,falseif all the given theme names were already present
-
addAll
-
remove
-
retainAll
-
removeAll
-
clear
public void clear() -
size
public int size() -
isEmpty
public boolean isEmpty() -
toArray
-
toArray
public <T> T[] toArray(T[] a) -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<String>- Specified by:
containsAllin interfaceSet<String>
-
toString
-