public final class StateModel extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
StateModel.Listener
The listener for listening on state changed event on a state model.
|
Constructor and Description |
---|
StateModel()
Creates a boolean (2-states) model.
|
StateModel(int maxStates)
Creates a model with a specified maximal states.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(StateModel.Listener listener)
Adds a listener of a state value changed.
|
void |
decrease()
Decreases the state value.
|
boolean |
getBooleanState()
Returns a boolean representation of a state.
|
int |
getMaxStates()
Returns a maximal states.
|
int |
getState()
Returns a integer representation of the state.
|
void |
increase()
Increases the state value.
|
void |
removeListener(StateModel.Listener listener)
Removes a listener of a state value changed.
|
void |
setBooleanState(boolean state)
Sets a boolean state.
|
void |
setState(int state)
Sets a new state value.
|
void |
toggleBooleanState()
Toggles boolean state.
|
public StateModel()
public StateModel(int maxStates)
maxStates
- the maximal statespublic boolean getBooleanState()
public void setBooleanState(boolean state)
state
- the boolean state; if true, then 1 value is used; if false, then 0 value is usedpublic void toggleBooleanState()
public int getState()
public void decrease()
public void increase()
public void setState(int state)
state
- the new state valuepublic int getMaxStates()
public void addListener(StateModel.Listener listener)
listener
- the listenerpublic void removeListener(StateModel.Listener listener)
listener
- the listener