java.lang.Object
org.maxicp.state.copy.Copier
- All Implemented Interfaces:
StateManager
StateManager that will store
the state of every created elements
at each
saveState() call.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetLevel()Returns the current level.makeStateInt(int initValue) Creates a Stateful integer (restorable)makeStateLong(long initValue) Creates a Stateful long (restorable)<K,V> StateMap <K, V> Creates a Stateful map (restorable)<T> State<T> makeStateRef(T initValue) Creates a Stateful reference (restorable)voidAdd a listener that is notified each time theStateManager.restoreState()is called.voidRestores state as it was at getLevel()-1 Decrease the level by 1voidrestoreStateUntil(int level) Restores the state up the the given level.voidStores the current state such that it can be recovered using restoreState() Increase the level by 1inttoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.maxicp.state.StateManager
withNewState, withNewState
-
Constructor Details
-
Copier
public Copier()
-
-
Method Details
-
onRestore
Description copied from interface:StateManagerAdd a listener that is notified each time theStateManager.restoreState()is called.- Specified by:
onRestorein interfaceStateManager- Parameters:
listener- the listener to be notified
-
getLevel
public int getLevel()Description copied from interface:StateManagerReturns the current level. It is increased at eachStateManager.saveState()and decreased at eachStateManager.restoreState(). It is initially equal to -1.- Specified by:
getLevelin interfaceStateManager- Returns:
- the level
-
storeSize
public int storeSize() -
saveState
public void saveState()Description copied from interface:StateManagerStores the current state such that it can be recovered using restoreState() Increase the level by 1- Specified by:
saveStatein interfaceStateManager
-
restoreState
public void restoreState()Description copied from interface:StateManagerRestores state as it was at getLevel()-1 Decrease the level by 1- Specified by:
restoreStatein interfaceStateManager
-
restoreStateUntil
public void restoreStateUntil(int level) Description copied from interface:StateManagerRestores the state up the the given level.- Specified by:
restoreStateUntilin interfaceStateManager- Parameters:
level- the level, a non negative number between 0 andStateManager.getLevel()
-
makeStateRef
Description copied from interface:StateManagerCreates a Stateful reference (restorable)- Specified by:
makeStateRefin interfaceStateManager- Parameters:
initValue- the initial setValue- Returns:
- a State object wrapping the initValue
-
makeStateInt
Description copied from interface:StateManagerCreates a Stateful integer (restorable)- Specified by:
makeStateIntin interfaceStateManager- Parameters:
initValue- the initial setValue- Returns:
- a StateInt object wrapping the initValue
-
makeStateLong
Description copied from interface:StateManagerCreates a Stateful long (restorable)- Specified by:
makeStateLongin interfaceStateManager- Parameters:
initValue- the initial setValue- Returns:
- a StateLong object wrapping the initValue
-
makeStateMap
Description copied from interface:StateManagerCreates a Stateful map (restorable)- Specified by:
makeStateMapin interfaceStateManager- Returns:
- a reference to the map.
-
toString
-