Package org.smooks.api.memento
Interface MementoCaretaker
-
- All Known Implementing Classes:
DefaultMementoCaretaker
public interface MementoCaretaker
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
capture(Memento memento)
Stores a copy of aMemento
.boolean
exists(Memento memento)
void
forget(Fragment<?> fragment)
Removes allMemento
s bound to theFragment
parameter.void
forget(Memento memento)
Removes theMemento
having an ID equal to theMemento
parameter's ID as returned byMemento.getAnchor()
.void
restore(Memento memento)
Mutates aMemento
to match the state of a savedMemento
.<T extends Memento>
Tstash(T defaultMemento, Function<T,T> function)
-
-
-
Method Detail
-
capture
void capture(Memento memento)
Stores a copy of aMemento
. It is the client's responsibility to remove the savedMemento
once it is no longer needed either by callingforget(Fragment)
orforget(Memento)
.- Parameters:
memento
- theMemento
to copy and store. After saving, mutations to thisMemento
should not alter the saved copy.
-
restore
void restore(Memento memento)
Mutates aMemento
to match the state of a savedMemento
. TheMemento
parameter is restored from a savedMemento
having an ID equal to its ID as returned byMemento.getAnchor()
. TheMemento
parameter remains unchanged if no such savedMemento
exists.- Parameters:
memento
- theMemento
to restore
-
exists
boolean exists(Memento memento)
-
forget
void forget(Memento memento)
Removes theMemento
having an ID equal to theMemento
parameter's ID as returned byMemento.getAnchor()
.- Parameters:
memento
- theMemento
to be removed
-
forget
void forget(Fragment<?> fragment)
Removes allMemento
s bound to theFragment
parameter.- Parameters:
fragment
- the fragment
-
stash
<T extends Memento> T stash(T defaultMemento, Function<T,T> function)
Invokes aConsumer
with a restoredMemento
and 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);
- Parameters:
defaultMemento
- theMemento
to be restoredfunction
- the function acting on the restoredMemento
and returning a newMemento replacing the earlier memento
- See Also:
restore(Memento)
,capture(Memento)
-
-