Module org.maxicp

Class Copier

java.lang.Object
org.maxicp.state.copy.Copier
All Implemented Interfaces:
StateManager

public class Copier extends Object implements StateManager
StateManager that will store the state of every created elements at each saveState() call.
  • Constructor Details

    • Copier

      public Copier()
  • Method Details

    • onRestore

      public void onRestore(Runnable listener)
      Description copied from interface: StateManager
      Add a listener that is notified each time the StateManager.restoreState() is called.
      Specified by:
      onRestore in interface StateManager
      Parameters:
      listener - the listener to be notified
    • getLevel

      public int getLevel()
      Description copied from interface: StateManager
      Returns the current level. It is increased at each StateManager.saveState() and decreased at each StateManager.restoreState(). It is initially equal to -1.
      Specified by:
      getLevel in interface StateManager
      Returns:
      the level
    • storeSize

      public int storeSize()
    • saveState

      public void saveState()
      Description copied from interface: StateManager
      Stores the current state such that it can be recovered using restoreState() Increase the level by 1
      Specified by:
      saveState in interface StateManager
    • restoreState

      public void restoreState()
      Description copied from interface: StateManager
      Restores state as it was at getLevel()-1 Decrease the level by 1
      Specified by:
      restoreState in interface StateManager
    • restoreStateUntil

      public void restoreStateUntil(int level)
      Description copied from interface: StateManager
      Restores the state up the the given level.
      Specified by:
      restoreStateUntil in interface StateManager
      Parameters:
      level - the level, a non negative number between 0 and StateManager.getLevel()
    • makeStateRef

      public <T> State<T> makeStateRef(T initValue)
      Description copied from interface: StateManager
      Creates a Stateful reference (restorable)
      Specified by:
      makeStateRef in interface StateManager
      Parameters:
      initValue - the initial setValue
      Returns:
      a State object wrapping the initValue
    • makeStateInt

      public StateInt makeStateInt(int initValue)
      Description copied from interface: StateManager
      Creates a Stateful integer (restorable)
      Specified by:
      makeStateInt in interface StateManager
      Parameters:
      initValue - the initial setValue
      Returns:
      a StateInt object wrapping the initValue
    • makeStateLong

      public StateLong makeStateLong(long initValue)
      Description copied from interface: StateManager
      Creates a Stateful long (restorable)
      Specified by:
      makeStateLong in interface StateManager
      Parameters:
      initValue - the initial setValue
      Returns:
      a StateLong object wrapping the initValue
    • makeStateMap

      public <K, V> StateMap<K,V> makeStateMap()
      Description copied from interface: StateManager
      Creates a Stateful map (restorable)
      Specified by:
      makeStateMap in interface StateManager
      Returns:
      a reference to the map.
    • toString

      public String toString()
      Overrides:
      toString in class Object