com.twitter.common.util
Class StateMachine.Rule<T>

java.lang.Object
  extended by com.twitter.common.util.StateMachine.Rule<T>
Type Parameters:
T - State type.
Enclosing class:
StateMachine<T>

public static class StateMachine.Rule<T>
extends Object

A state and its allowed transitions (if any) and (optional) callback.


Nested Class Summary
static class StateMachine.Rule.AllowedTransition<T>
          A helper class when building a transition rule, to define the allowed transitions.
 
Method Summary
static
<T> StateMachine.Rule.AllowedTransition<T>
from(T state)
          Creates a new transition rule.
 StateMachine.Rule<T> withCallback(Closure<StateMachine.Transition<T>> callback)
          Associates a callback to be triggered after any attempt to transition from this state is made.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withCallback

public StateMachine.Rule<T> withCallback(Closure<StateMachine.Transition<T>> callback)
Associates a callback to be triggered after any attempt to transition from this state is made.

Parameters:
callback - Callback to signal.
Returns:
A new rule that is identical to this rule, but with the provided callback

from

public static <T> StateMachine.Rule.AllowedTransition<T> from(T state)
Creates a new transition rule.

Type Parameters:
T - State type.
Parameters:
state - State to create and associate transitions with.
Returns:
A new transition rule builder.