Without violating encapsulation, the intent of this pattern is to capture the internal state of an object so that the object can be restored to this state later.
Memento pattern is used to implement this in such a way that the saved state data of the object is not accessible outside of the object; this protects the integrity of saved state data.
The classes and objects participating in this pattern are:
Example of memento pattern
Mechanism of rolling back the transaction can be achieved by memento design pattern.
Example in Java's core libraries:
java.util.Date (the setter methods do that, Date is internally represented by a long value)
All implementations of java.io.Serializable
All implementations of javax.faces.component.StateHolder