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

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

public static class StateMachine.Transition<T>
extends Object

Representation of a state transition.


Constructor Summary
StateMachine.Transition(T from, T to, boolean allowed)
           
 
Method Summary
 boolean equals(Object o)
           
static
<T> Predicate<StateMachine.Transition<T>>
from(T... states)
          Creates a predicate that returns true for transitions from the given states.
 T getFrom()
           
 T getTo()
           
 int hashCode()
           
 boolean isAllowed()
           
 boolean isValidStateChange()
          Checks whether this transition represents a state change, which means that the 'to' state is not equal to the 'from' state, and the transition is allowed.
static
<T> Predicate<StateMachine.Transition<T>>
to(T... states)
          Creates a predicate that returns true for transitions to the given states.
 String toString()
           
static
<T> Predicate<StateMachine.Transition<T>>
transition(T from, T to)
          Creates a predicate that returns true for a specific state transition.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StateMachine.Transition

public StateMachine.Transition(T from,
                               T to,
                               boolean allowed)
Method Detail

from

public static <T> Predicate<StateMachine.Transition<T>> from(T... states)
Creates a predicate that returns true for transitions from the given states.

Type Parameters:
T - State type.
Parameters:
states - States to filter on.
Returns:
A from-state filter.

to

public static <T> Predicate<StateMachine.Transition<T>> to(T... states)
Creates a predicate that returns true for transitions to the given states.

Type Parameters:
T - State type.
Parameters:
states - States to filter on.
Returns:
A to-state filter.

transition

public static <T> Predicate<StateMachine.Transition<T>> transition(T from,
                                                                   T to)
Creates a predicate that returns true for a specific state transition.

Type Parameters:
T - State type.
Parameters:
from - From state.
to - To state.
Returns:
A state transition filter.

getFrom

public T getFrom()

getTo

public T getTo()

isAllowed

public boolean isAllowed()

isValidStateChange

public boolean isValidStateChange()
Checks whether this transition represents a state change, which means that the 'to' state is not equal to the 'from' state, and the transition is allowed.

Returns:
true if the state was changed, false otherwise.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object