org.jboss.cache.optimistic
Class DefaultDataVersion

java.lang.Object
  extended by org.jboss.cache.optimistic.DefaultDataVersion
All Implemented Interfaces:
java.io.Serializable, DataVersion

public class DefaultDataVersion
extends java.lang.Object
implements DataVersion

The default implementation of a DataVersion, uses a long to compare versions. This class is immutable.

Also note that this is meant to control implicit, internal versioning. Do not attempt to instantiate or use instances of this class explicitly, via the Option.setDataVersion(DataVersion) API, as it WILL break things.

Author:
Manik Surtani (manik@jboss.org)
See Also:
Serialized Form

Field Summary
static DataVersion ZERO
          Version zero.
 
Constructor Summary
DefaultDataVersion()
          Constructs with version 0.
DefaultDataVersion(long version)
          Constructs with a version number.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 long getRawVersion()
           
 int hashCode()
           
 DataVersion increment()
          Returns a new DataVersion with a newer version number.
 boolean newerThan(DataVersion other)
          Returns true if this is a newer version than other.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final DataVersion ZERO
Version zero. Assign this as the first version to your data.

Constructor Detail

DefaultDataVersion

public DefaultDataVersion()
Constructs with version 0.


DefaultDataVersion

public DefaultDataVersion(long version)
Constructs with a version number.

Method Detail

increment

public DataVersion increment()
Returns a new DataVersion with a newer version number.


newerThan

public boolean newerThan(DataVersion other)
Description copied from interface: DataVersion
Returns true if this is a newer version than other. There is no guarantee that the DataVersion passed in is of the same implementation as the current instance. The implementation will have to check for this (if necessary) and (if necessary) throw a DataVersioningException.

Specified by:
newerThan in interface DataVersion

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getRawVersion

public long getRawVersion()