com.levigo.util.base
Class CompositeMemento

java.lang.Object
  extended by com.levigo.util.base.CompositeMemento
All Implemented Interfaces:
Memento

public class CompositeMemento
extends Object
implements Memento

A composite memento that encompasses a collection or an array of MementoOriginators.


Constructor Summary
CompositeMemento(Collection<? extends MementoOriginator> originators)
          Create a composite memento for all given originators.
CompositeMemento(Collection<? extends MementoOriginator> originators, boolean saveImmediately)
          Create a composite memento for all given originators.
 
Method Summary
 void clear()
          Clear this memento so that restore()ing will have no effect.
 void restore()
          Restore this memento's originator to its state at the time when this memento was created.
 void save()
          Update this memento's state with the current state of the originators given at construction time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeMemento

public CompositeMemento(Collection<? extends MementoOriginator> originators)
Create a composite memento for all given originators. Mementos will be requested immediately for all member originators. Calling restore() on this composite memento will restore all mementos provided by the those originators.

Parameters:
originators - the memento originators

CompositeMemento

public CompositeMemento(Collection<? extends MementoOriginator> originators,
                        boolean saveImmediately)
Create a composite memento for all given originators. Calling restore() on this composite memento will restore all mementos provided by the those originators. If saveImmediately is true, mementos will be requested immediately for all member originators. Otherwise they can be requested later on using save().

Parameters:
originators - the memento originators
saveImmediately - whether to save the member mementos immediately
Method Detail

save

public void save()
Update this memento's state with the current state of the originators given at construction time.


clear

public void clear()
Clear this memento so that restore()ing will have no effect.


restore

public void restore()
Description copied from interface: Memento
Restore this memento's originator to its state at the time when this memento was created.

Specified by:
restore in interface Memento


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.