org.prevayler.util.memento
Class Memento

java.lang.Object
  extended by org.prevayler.util.memento.Memento

public abstract class Memento
extends Object

A memento is a snapshot of an object before it gets changed. A copy of all fields under the objects control should be made.

Version:
2.0
Author:
Johan Stuyts

Constructor Summary
Memento()
           
 
Method Summary
 boolean equals(Object other)
          Compare this memento with another.
protected abstract  Object getOwner()
          Get the object to which this memento belongs.
 int hashCode()
          The hash code of this object.
protected abstract  void restore()
          Restore the values of the object to the values in this memento.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Memento

public Memento()
Method Detail

restore

protected abstract void restore()
Restore the values of the object to the values in this memento. It is very important that the implementation does not throw any checked and run-time exceptions.


getOwner

protected abstract Object getOwner()
Get the object to which this memento belongs.

Returns:
The object to which this memento belongs.

hashCode

public int hashCode()
The hash code of this object. This is used in some sets and maps. As it is very important that only the first memento of an object gets stored, this method returns the identity hash code of the owner.

Overrides:
hashCode in class Object
Returns:
The hash code of this memento.

equals

public boolean equals(Object other)
Compare this memento with another. This is used in some sets and maps. As it is very important that only the first memento of an object gets stored, this method returns true if the class of the other object is the same (identity comparison) class as the class of this memento, and the owner of the other memento is the same (identity comparison) as the owner of this memento.

Overrides:
equals in class Object
Returns:
true if the other memento is a memento for the same object, false otherwise.


Copyright © 2001-2013. All Rights Reserved.