StateType
- public abstract class AbstractActivity<StateType>
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected StateType |
endState |
protected StateType |
startState |
protected java.util.concurrent.CountDownLatch |
stateChangedLatch |
Constructor and Description |
---|
AbstractActivity(StateType start,
StateType end) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterStateChanged(StateType newValue) |
protected boolean |
compareAndSetState(StateType oldState,
StateType newState)
Moves to a new state (newState) if the current state is equal to a given
state (oldState)
|
protected abstract void |
doRun()
Overriden by implementors to do the actual work
|
StateType |
getEndState()
Return the object indicating an ending state for this activity.
|
StateType |
getStartState()
Return the object indicating a starting state for this activity.
|
protected StateType |
getState() |
protected abstract void |
initiate()
Called by the framework to initiate a new activity.
|
protected boolean |
isStopped()
returns true if the end state was set and is the current state
|
void |
run() |
protected void |
setState(StateType newValue) |
void |
setStateListener(java.lang.Object state,
ActivityStateListener listener) |
protected final StateType startState
protected final StateType endState
protected java.util.concurrent.CountDownLatch stateChangedLatch
protected abstract void initiate()
Called by the framework to initiate a new activity. This method is only invoked
at the peer initiating the activity. Once an activity has been initiated, its state
changes to start
.
protected abstract void doRun()
public void run()
run
in interface java.lang.Runnable
protected boolean isStopped()
protected void afterStateChanged(StateType newValue)
protected boolean compareAndSetState(StateType oldState, StateType newState)
oldState
- newState
- protected StateType getState()
protected void setState(StateType newValue)
public void setStateListener(java.lang.Object state, ActivityStateListener listener)
public StateType getStartState()
Return the object indicating a starting state for this activity.
public StateType getEndState()
Return the object indicating an ending state for this activity.