|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jaer.util.StateMachineStates
public abstract class StateMachineStates
Class that keeps track of state of state machine, allowing access to previous state, time since state changed, defining an initial state. Use it like this:
enum StateMachineStates{INITIAL, MIDDLE, FINAL} // define states class S extends StateMachineStates{ // extends StateMachineStates and implement the getInitial method StateMachineStates state=StateMachineStates.INITIAL; public Enum getInitial(){ return StateMachineStates.INITIAL; } }Use the enum to define the states and then the set and get methods to set and get the state.
S s=new S(); s.set(StateMachineStates.MIDDLE); s.getPrevious(); s.timeSinceChanged();
Constructor Summary | |
---|---|
StateMachineStates()
Create a new state machine. |
|
StateMachineStates(java.lang.Enum initialState)
Create a new state machine with defined initial state. |
Method Summary | |
---|---|
boolean |
equals(StateMachineStates other)
|
java.lang.Enum |
get()
Return present state |
abstract java.lang.Enum |
getInitial()
Defines the default initial state |
java.lang.Enum |
getPrevious()
return previous state, before it was changed. |
boolean |
isChanged()
was the currentState changed the last time it was set(java.lang.Enum) ? |
boolean |
isInitialized()
has state been initialized or set away from it's Integer.MIN_VALUE initial state? |
void |
set(java.lang.Enum newState)
set a possibly new currentState. |
long |
timeSinceChanged()
return time in ms since state last changed |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StateMachineStates(java.lang.Enum initialState)
initialState
- a new initial statepublic StateMachineStates()
Method Detail |
---|
public abstract java.lang.Enum getInitial()
public void set(java.lang.Enum newState)
isChanged()
is called, it returns false
.
newState
- the new state to be inpublic boolean isChanged()
set(java.lang.Enum)
?
public long timeSinceChanged()
public java.lang.Enum get()
public java.lang.Enum getPrevious()
public boolean isInitialized()
Integer.MIN_VALUE
initial state?
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(StateMachineStates other)
|
jAER project on SourceForge | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |