com.tc.util
Class AbstractIdentifier

java.lang.Object
  extended by com.tc.util.AbstractIdentifier
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable
Direct Known Subclasses:
ObjectID, ThreadID

public abstract class AbstractIdentifier
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Generic Identifier class, parent class of many ID types. Legal identifiers are expected to be >= 0 and -1 represents a "null" identifier.

Author:
steve
See Also:
Serialized Form

Constructor Summary
protected AbstractIdentifier()
          Create a null identifier
  AbstractIdentifier(long id)
          Create an identifier with a long value, which is expected to be >= 0.
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object obj)
          Equality is based on the id value and the identifier class.
abstract  java.lang.String getIdentifierType()
          Subclasses of AbstractIdentifier specify their "type" by implementing this method and returning a string.
 int hashCode()
           
 boolean isNull()
          Check whether the identifier is null (-1).
 long toLong()
          Convert to long
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractIdentifier

public AbstractIdentifier(long id)
Create an identifier with a long value, which is expected to be >= 0.


AbstractIdentifier

protected AbstractIdentifier()
Create a null identifier

Method Detail

isNull

public boolean isNull()
Check whether the identifier is null (-1).

Returns:
True if -1, false otherwise

toLong

public final long toLong()
Convert to long

Returns:
Long identifier value

toString

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

getIdentifierType

public abstract java.lang.String getIdentifierType()
Subclasses of AbstractIdentifier specify their "type" by implementing this method and returning a string. The type is used in printing toString().


hashCode

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

equals

public boolean equals(java.lang.Object obj)
Equality is based on the id value and the identifier class.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.