Package Behavioral.Memento
Class Originator
java.lang.Object
Behavioral.Memento.Originator
The Originator class creates and restores Memento objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a Memento containing the current state.getState()Retrieves the current state of the Originator.voidrestoreMemento(Memento memento) Restores the state from a given Memento.voidSets the state of the Originator.
-
Constructor Details
-
Originator
public Originator()Default constructor for Originator.
-
-
Method Details
-
setState
Sets the state of the Originator.- Parameters:
state- The new state.
-
getState
Retrieves the current state of the Originator.- Returns:
- The current state as a string.
-
createMemento
Creates a Memento containing the current state.- Returns:
- A new Memento instance with the current state.
-
restoreMemento
Restores the state from a given Memento.- Parameters:
memento- The Memento to restore from.
-