|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A set representing a state value containing none or more non-null "state flag" objects. The contents of the set (flag types and combinations) and its state transitions are ruled by a state policy. State set mutators work as expected, clearing, adding, and removing elements from this set, but as mediated by the state policy for state transit, if any. Also, null elements are not allowed in the set. Mutators with a null object parameter should perform a state transition but silently ignore the null element (do not add or remove it from the set). If the state policy implements a classic finite state machine, with transitions driven only by current state and inputs, implementations should consider throwing UnsupportedOperationException for all mutators except reset() and transit().
The identity (equals(), hashCode()) of a state set is that of a Set. This may be unsatisfactory in situations requiring equality of the state sets's current and old state, in which case both states must be tested for equality.
Method Summary | |
boolean |
change(java.lang.Object remove,
java.lang.Object add)
Removes then adds the specified state flags, as allowed by the state policy. |
boolean |
change(StateSet changes)
Performs a "masked change" by imposing a target's state set changes (deltas) on this state set, as allowed by the state policy, with the union of the target's old and new states acting as the mask. |
boolean |
changeAll(java.util.Collection remove,
java.util.Collection add)
Removes then adds the specified state flags, as allowed by the state policy. |
java.util.Set |
getOldState()
Gets a singleton immutable view of this set's old state value, which was the state value prior to the last transit, or the same state value as the current one after a reset. |
StatePolicy |
getStatePolicy()
Gets the state policy for this state set, which assures that the state value contains valid combinations and types of state flags following state initialization and transition. |
StateSet |
getStateSet()
Gets a singleton immutable view of this set, which is the current state value, resulting from the last reset or transit. |
boolean |
reset(java.util.Collection state)
Resets (re-initializes) this state set's value to a new state, as allowed by the state policy. |
boolean |
set(java.util.Collection state)
Sets this state set's value to a new state, as allowed by the state policy. |
boolean |
transit(java.util.Collection input)
Causes this state set's value to transit from one state to another (possibly with no change in value) according to an input value. |
Methods inherited from interface java.util.Set |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Method Detail |
public StatePolicy getStatePolicy()
public boolean reset(java.util.Collection state)
state
- The new state value (Object). Never null.
public boolean set(java.util.Collection state)
state
- The new state value (Object). Never null.
public boolean change(StateSet changes)
changes
- The state value changes. Never null.
public boolean change(java.lang.Object remove, java.lang.Object add)
remove
- Flag to be removed. None if null.add
- Flag to be added. None if null.
public boolean changeAll(java.util.Collection remove, java.util.Collection add)
remove
- Flags to be removed. Never null.add
- Flags to be added. Never null.
public boolean transit(java.util.Collection input)
input
- The input value (Object). Never null.
public StateSet getStateSet()
public java.util.Set getOldState()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |