Static Class Structure
Caretaker
Originator class
to save and restore originator's
internal state.
Memento objects,
created and returned by the originator,
and passes back a memento to the
originator
to restore to a previous state.
Memento object.
Originator
createMemento())
for saving its current internal state
to a Memento object.
restore(memento))
for restoring to a previous state
from a passed in Memento object.
Memento
Dynamic Object Collaboration
Originator object.
Originator's
current internal state,
the Caretaker
calls createMemento()
on the Originator.
Originator creates a new
Memento object, saves
its current internal state
(setState()),
and returns the Memento object
to the Caretaker.
Caretaker holds (takes care of)
the returned Memento object(s).
Originator
to a previous state,
the Caretaker calls
restore(memento)
on the Originator
by providing the Memento object
to be restored.
Originator gets the
state to be restored
from the provided Memento object
(getState()).