package net.sourceforge.pain.db;
import java.io.*;
/**
* Serializable DbObject ID
*/
public final class DbOid implements Serializable {
int indexId;
long versionId;
private int hashCode;
public DbOid() {
hashCode = 0;
}
DbOid(final int indexId, final long versionId) {
this.indexId = indexId;
this.versionId = versionId;
hashCode = 0;
}
public String toString() {
return "[" + indexId + "/" + versionId + "]";
}
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DbOid)) {
return false;
}
final DbOid dbOid = (DbOid) o;
if (indexId != dbOid.indexId) {
return false;
}
if (versionId != dbOid.versionId) {
return false;
}
return true;
}
public int hashCode() {
if (hashCode == 0) {
hashCode = generateHashCode();
}
return hashCode;
}
private int generateHashCode() {
int result;
result = indexId;
result = 29 * result + (int) (versionId ^ (versionId >>> 32));
result = 29 * result + hashCode;
return result;
}
/** this method use knowledge about PAiN DB internals
* it public only for use with PAiN Mud Codebase
*/
public int getIndexId() {
return indexId;
}
/** this method use knowledge about PAiN DB internals
* it public only for use with PAiN Mud Codebase
*/
public long getVersionId() {
return versionId;
}
}