java.lang.Object
org.omnifaces.util.State
Helper class for StateHelper that uses generic type-inference to make code that uses the StateHelper slightly less verbose.
- Since:
- 1.1
- Author:
- Arjan Tijms
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Tget(Serializable key) Attempts to find a value associated with the specified key in the component's state.<T> Tget(Serializable key, Object defaultValue) Attempts to find a value associated with the specified key in the component's state.<T> Tput(Serializable key, T value) Puts a value in the component's state and returns the previous value.
-
Constructor Details
-
State
-
-
Method Details
-
get
Attempts to find a value associated with the specified key in the component's state.- Type Parameters:
T- The expected return type.- Parameters:
key- the name of the value in component's state- Returns:
- The value associated with the specified key.
- Throws:
ClassCastException- WhenTis of wrong type.
-
get
Attempts to find a value associated with the specified key in the component's state.- Type Parameters:
T- The expected return type.- Parameters:
key- the name of the value in component's statedefaultValue- the value to return if no value is found in the call to get()- Returns:
- The value associated with the specified key, or the given default value if no value is found.
- Throws:
ClassCastException- WhenTis of wrong type.
-
put
Puts a value in the component's state and returns the previous value. Note that the previous value has to be of the same type as the value being set. If this is unwanted, use the original StateHelper.- Type Parameters:
T- The expected value and return type.- Parameters:
key- The name of the value in component's state.value- The value to put in component's state.- Returns:
- The previous value, if any.
- Throws:
ClassCastException- WhenTis of wrong type.
-