org.jcoderz.guidelines.snippets
Class TransactionId

java.lang.Object
  extended by org.jcoderz.guidelines.snippets.TransactionId
All Implemented Interfaces:
Serializable, Comparable

public final class TransactionId
extends Object
implements Comparable, Serializable

This util class represents an Transaction Id with all of its features and restrictions. Instances of this class are immutable.

Author:
SWAG
See Also:
Serialized Form

Field Summary
static String TYPE_NAME
          Name of this type.
 
Method Summary
 int compareTo(Object o)
          Compare two transaction IDs.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
static TransactionId fromLong(long l)
          Returns a transaction id from the given long l.
static TransactionId fromString(String s)
          Parses the string argument as a transaction id.
 int hashCode()
          Compute hash code.
 long toLong()
          Returns the transaction id as long.
 String toString()
          Returns the transaction id as String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_NAME

public static final String TYPE_NAME
Name of this type.

See Also:
Constant Field Values
Method Detail

fromString

public static TransactionId fromString(String s)
                                throws IllegalArgumentException
Parses the string argument as a transaction id.

Parameters:
s - the String containing the transaction id.
Returns:
the transaction id represented by the string argument.
Throws:
IllegalArgumentException - if the string does not contain a parseable transaction id.

fromLong

public static TransactionId fromLong(long l)
                              throws IllegalArgumentException
Returns a transaction id from the given long l.

Parameters:
l - the long containing the transaction id.
Returns:
the transaction id represented by the argument.
Throws:
IllegalArgumentException - if the long does not fit into a transaction id.

toString

public String toString()
Returns the transaction id as String.

Overrides:
toString in class Object
Returns:
the transaction id as String.

toLong

public long toLong()
Returns the transaction id as long.

Returns:
the transaction id as long.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class Object
Parameters:
obj - the object to compare this TransactionId against.
Returns:
true if this object is the same as the obj argument; false otherwise.

compareTo

public int compareTo(Object o)
Compare two transaction IDs. This implementation is consistent with equals(Object).

Specified by:
compareTo in interface Comparable
Parameters:
o - object with which to compare this TransactionId
Returns:
a result less than zero if this object is less than o, exactly zero if they are equal, and a result greater than zero otherwise.

hashCode

public int hashCode()
Compute hash code.

Overrides:
hashCode in class Object
Returns:
hash code for this transaction ID


Copyright 2007 The jCoderZ Project.