File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
memento/src/main/java/com/iluwatar/memento Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 4
4
5
5
/**
6
6
*
7
- * Memento pattern is for storing and restoring object state. The object ({@link Star})
7
+ * The Memento pattern is a software design pattern that provides the ability to restore
8
+ * an object to its previous state (undo via rollback).
9
+ * <p>
10
+ * The Memento pattern is implemented with three objects: the originator, a caretaker and
11
+ * a memento. The originator is some object that has an internal state. The caretaker is
12
+ * going to do something to the originator, but wants to be able to undo the change. The
13
+ * caretaker first asks the originator for a memento object. Then it does whatever operation
14
+ * (or sequence of operations) it was going to do. To roll back to the state before the
15
+ * operations, it returns the memento object to the originator. The memento object itself
16
+ * is an opaque object (one which the caretaker cannot, or should not, change). When using
17
+ * this pattern, care should be taken if the originator may change other objects or
18
+ * resources - the memento pattern operates on a single object.
19
+ * <p>
20
+ * In this example the object ({@link Star})
8
21
* gives out a "memento" ({@link StarMemento}) that contains the state of the object.
9
22
* Later on the memento can be set back to the object restoring the state.
10
23
*
You can’t perform that action at this time.
0 commit comments