T
- the Enumeration type to manage by the switcherpublic abstract class CssSwitcher<T extends Enum<T>> extends Object
The switcher defines the CSS class that corresponds to each enumeration constant which avoid polluting the enumeration with the same boilerplate code for storing and accessing the corresponding CSS class.
Inside the component, the switcher manages the switching between the CSS classes. The switcher is responsible for applying the appropriate CSS class and then removing the previously set CSS class when a new class is applied.
Map
member to hold the mapping between the enumeration
constants and the CSS class related to the enumerations.getMappings()
that returns the mappings stored in the
static member defined earlier. The mappings can be defined in a static block
or during the first invocation of the method. But either way, there should
always be a single copy of the mappings to optimize memory consumption.Constructor and Description |
---|
CssSwitcher() |
Modifier and Type | Method and Description |
---|---|
protected abstract Map<T,String> |
getMappings()
The mapping is defined in sub-types to enable the switcher to pick the
appropriate CSS class for a given enumeration option.
|
com.google.gwt.dom.client.Element |
getTarget() |
T |
getValue() |
void |
setTarget(com.google.gwt.dom.client.Element inputTarget)
The element managed by the CSS switcher.
|
void |
setValue(T inputValue) |
String |
toString() |
public final void setTarget(com.google.gwt.dom.client.Element inputTarget)
inputTarget
- the DOM element managed by the CSS switcherpublic final com.google.gwt.dom.client.Element getTarget()
public final void setValue(T inputValue)
inputValue
- the enumeration option to be setpublic final T getValue()
public final String toString()
Copyright © 2016 com.github.ilyes4j. All rights reserved.