gumbo.interact
Class InteractorPolicy

java.lang.Object
  |
  +--gumbo.util.state.AbstractStatePolicy
        |
        +--gumbo.interact.InteractorPolicy
All Implemented Interfaces:
StatePolicy

public class InteractorPolicy
extends AbstractStatePolicy

Default state update policy for use with the standard interactor state values and flags (see InteractorFlag and InteractorFlags). This state policy is stateless and employs fail-fast enforcement, throwing an exception if an invalid state occurs.

Version:
$Revision: 1.2 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
protected InteractorPolicy()
          Creates an instance.
 
Method Summary
protected  void checkNewFlags(java.util.Collection flags)
          Called by this policy to check new state value flag types.
protected  void checkNewState(java.util.Set state)
          Only checks new flags; old flags are ignored (stateless).
static InteractorPolicy getInstance()
          Gets the singleton instance of this class.
 boolean isCompatible(StatePolicy policy)
          Returns true if another policy is assignment compatible with this policy.
 
Methods inherited from class gumbo.util.state.AbstractStatePolicy
checkInitialState, checkTransitState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InteractorPolicy

protected InteractorPolicy()
Creates an instance. Typically, this class is used as a singleton (see getInstance()). As such, this constructor is only used to extend the class.

Method Detail

checkNewFlags

protected void checkNewFlags(java.util.Collection flags)
Description copied from class: AbstractStatePolicy
Called by this policy to check new state value flag types. Modify the flags or throw an exception if a flag is invalid.

Specified by:
checkNewFlags in class AbstractStatePolicy
Throws:
java.lang.IllegalStateException - Flags must be type InteractorFlag.

checkNewState

protected void checkNewState(java.util.Set state)
Only checks new flags; old flags are ignored (stateless). Checks for bad flags (???_NONE not allowed), exclusive-or flags (none or one ???_XOR_MASK flag set), and mutually exclusive flags (one and only one ???_ONE_MASK flag set) for each flag group (ACTION_???, CONTROL_???, STATUS_???, SELECT_???). Note that there are no restrictions on select flags other than that imposed by the identity of the select flags in a state set (only one select flag with a given subtype, order, and data model).

Specified by:
checkNewState in class AbstractStatePolicy
Parameters:
state - Reference to the new state (Object). Never null.
Throws:
java.lang.IllegalStateException - ???_NONE flags not allowed.

isCompatible

public boolean isCompatible(StatePolicy policy)
Returns true if another policy is assignment compatible with this policy.

Specified by:
isCompatible in interface StatePolicy
Overrides:
isCompatible in class AbstractStatePolicy
Parameters:
policy - Other state policy. None if null.
Returns:
True if the other policy (or the lack of a policy, if policy is null) is compatible with this one.

getInstance

public static InteractorPolicy getInstance()
Gets the singleton instance of this class.

Returns:
Reference to the singleton instance. Never null.