com.alachisoft.ncache.client.CacheItemVersion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.client;
/**
* Represents the version of each cache item. An instance of this class is used
* in the optimistic concurrency model to ensure the data integrity.
*/
public class CacheItemVersion implements Comparable {
private long _version;
public CacheItemVersion() {
_version = 0;
}
public CacheItemVersion(long version) {
_version = version;
}
// /**
// *
// * @param version
// * @deprecated to get GacheItemVersion, use the Cache.getCacheItem("key") command and extract the version information from it
// */
// public CacheItemVersion(long version)
// {
// this._version = version;
// }
/**
* Get item version
*
* @return Item's version
*/
public long getVersion() {
return this._version;
}
/**
* Set item version
*
* @param version Item's version
*/
public void setVersion(long version) {
this._version = version;
}
/**
* The string representation of this class.
*
* @return a string representation of the object.
*/
@Override
public String toString() {
return Long.toString(this._version);
}
/**
* Compare CacheItemVersion with current instance of item version
*
* @param itemVersion item version to be compared
* @return 0 if two instance are equal. An integer greater then 0 if
* this instance is greater. An integer less than 0 if this instance is smaller
*/
public int compareTo(CacheItemVersion itemVersion) {
if (itemVersion == null) {
return -1;
}
long version = itemVersion._version;
if (version == this._version) {
return 0;
}
if (version < this._version) {
return 1;
}
if (version > this._version) {
return -1;
}
return -1;
}
}