Class Originator

java.lang.Object
Behavioral.Memento.Originator

public class Originator extends Object
The Originator class creates and restores Memento objects.
  • Constructor Details

    • Originator

      public Originator()
      Default constructor for Originator.
  • Method Details

    • setState

      public void setState(String state)
      Sets the state of the Originator.
      Parameters:
      state - The new state.
    • getState

      public String getState()
      Retrieves the current state of the Originator.
      Returns:
      The current state as a string.
    • createMemento

      public Memento createMemento()
      Creates a Memento containing the current state.
      Returns:
      A new Memento instance with the current state.
    • restoreMemento

      public void restoreMemento(Memento memento)
      Restores the state from a given Memento.
      Parameters:
      memento - The Memento to restore from.