goldengate.common.state
Class MachineState<EnumState>

java.lang.Object
  extended by goldengate.common.state.MachineState<EnumState>
Type Parameters:
EnumState -

public class MachineState<EnumState>
extends Object

This is the base class for the basic support of Finite State Machine in GoldenGate. One need to implement an Enum class to use with it.

Note: the type EnumSet< ? > is in fact of type EnumSet< EnumState >

Author:
Frederic Bregier

Constructor Summary
MachineState(EnumState initialState)
          Initialize with an initialState but no association (Machine State is empty)
MachineState(EnumState initialState, ConcurrentHashMap<EnumState,EnumSet<?>> map)
          Initialize with an initialState
 
Method Summary
 EnumSet<?> addNewAssociation(EnumState state, EnumSet<?> set)
          Add a new association from one state to a set of acceptable following states (can replace an existing association)
 EnumSet<?> addNewAssociation(Transition<EnumState> elt)
          Add a new association from one state to a set of acceptable following states (can replace an existing association)
 EnumState getCurrent()
          Return the current application state.
 void release()
          Release the Machine State
 EnumSet<?> removeAssociation(EnumState state)
          Remove an association from one state to any acceptable following states
 EnumState setCurrent(EnumState desiredState)
          Sets the current application state.
 EnumState setDryCurrent(EnumState desiredState)
          Sets the current application state, but no exception if not compatible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MachineState

public MachineState(EnumState initialState,
                    ConcurrentHashMap<EnumState,EnumSet<?>> map)
Initialize with an initialState

Parameters:
initialState - initial MachineState
map - the association of state and set of acceptable following states

MachineState

public MachineState(EnumState initialState)
Initialize with an initialState but no association (Machine State is empty)

Parameters:
initialState - initial MachineState
Method Detail

addNewAssociation

public EnumSet<?> addNewAssociation(EnumState state,
                                    EnumSet<?> set)
Add a new association from one state to a set of acceptable following states (can replace an existing association)

Parameters:
state -
set - the new association
Returns:
the previous association if any

addNewAssociation

public EnumSet<?> addNewAssociation(Transition<EnumState> elt)
Add a new association from one state to a set of acceptable following states (can replace an existing association)

Parameters:
elt -
Returns:
the previous association if any

removeAssociation

public EnumSet<?> removeAssociation(EnumState state)
Remove an association from one state to any acceptable following states

Parameters:
state - the state to remove any acceptable following states
Returns:
the previous association if any

getCurrent

public EnumState getCurrent()
Return the current application state.

Returns:
the current State

setCurrent

public EnumState setCurrent(EnumState desiredState)
                     throws IllegalFiniteStateException
Sets the current application state.

Parameters:
desiredState -
Returns:
the requested state, if it was reachable
Throws:
IllegalFiniteStateException - if the state is not allowed

setDryCurrent

public EnumState setDryCurrent(EnumState desiredState)
Sets the current application state, but no exception if not compatible.

Parameters:
desiredState -
Returns:
the requested state, even if it was not reachable

release

public void release()
Release the Machine State



Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.