Package org.smooks.engine.memento
Class DefaultMementoCaretaker
- java.lang.Object
-
- org.smooks.engine.memento.DefaultMementoCaretaker
-
- All Implemented Interfaces:
MementoCaretaker
@NotThreadSafe public class DefaultMementoCaretaker extends Object implements MementoCaretaker
-
-
Constructor Summary
Constructors Constructor Description DefaultMementoCaretaker(TypedMap typedMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcapture(Memento memento)Stores a copy of aMemento.booleanexists(Memento memento)voidforget(Fragment<?> fragment)Removes allMementos bound to theFragmentparameter.voidforget(Memento visitorMemento)Removes theMementohaving an ID equal to theMementoparameter's ID as returned byMemento.getAnchor().voidrestore(Memento memento)Mutates aMementoto match the state of a savedMemento.<T extends Memento>
Tstash(T defaultMemento, Function<T,T> function)
-
-
-
Constructor Detail
-
DefaultMementoCaretaker
public DefaultMementoCaretaker(TypedMap typedMap)
-
-
Method Detail
-
capture
public void capture(Memento memento)
Description copied from interface:MementoCaretakerStores a copy of aMemento. It is the client's responsibility to remove the savedMementoonce it is no longer needed either by callingMementoCaretaker.forget(Fragment)orMementoCaretaker.forget(Memento).- Specified by:
capturein interfaceMementoCaretaker- Parameters:
memento- theMementoto copy and store. After saving, mutations to thisMementoshould not alter the saved copy.
-
restore
public void restore(Memento memento)
Description copied from interface:MementoCaretakerMutates aMementoto match the state of a savedMemento. TheMementoparameter is restored from a savedMementohaving an ID equal to its ID as returned byMemento.getAnchor(). TheMementoparameter remains unchanged if no such savedMementoexists.- Specified by:
restorein interfaceMementoCaretaker- Parameters:
memento- theMementoto restore
-
exists
public boolean exists(Memento memento)
- Specified by:
existsin interfaceMementoCaretaker
-
forget
public void forget(Memento visitorMemento)
Description copied from interface:MementoCaretakerRemoves theMementohaving an ID equal to theMementoparameter's ID as returned byMemento.getAnchor().- Specified by:
forgetin interfaceMementoCaretaker- Parameters:
visitorMemento- theMementoto be removed
-
forget
public void forget(Fragment<?> fragment)
Description copied from interface:MementoCaretakerRemoves allMementos bound to theFragmentparameter.- Specified by:
forgetin interfaceMementoCaretaker- Parameters:
fragment- the fragment
-
stash
public <T extends Memento> T stash(T defaultMemento, Function<T,T> function)
Description copied from interface:MementoCaretakerInvokes aConsumerwith a restoredMementoand then saves theMemento. This method offers a convenient way to aggregate and save data instead of writing:mementoCaretaker.restore(Memento); // add data to memento // ... mementoCaretaker.save(memento);
- Specified by:
stashin interfaceMementoCaretaker- Parameters:
defaultMemento- theMementoto be restoredfunction- the function acting on the restoredMementoand returning a newMemento replacing the earlier memento- See Also:
MementoCaretaker.restore(Memento),MementoCaretaker.capture(Memento)
-
-