Package org.apache.torque.om
Class ObjectKey<T>
java.lang.Object
org.apache.torque.om.ObjectKey<T>
- All Implemented Interfaces:
Serializable,Comparable<Object>
This class can be used to uniquely identify an object within
an application. There are four subclasses: StringKey, NumberKey,
and DateKey, and ComboKey which is a Key made up of a combination
of the first three.
- Version:
- $Id: ObjectKey.java 1917245 2024-04-21 14:06:23Z tv $
- Author:
- John McNally
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends a String representation of the key to a buffer.intImplements the compareTo method.booleanReturns whether this ObjekctKey is equal to another Object.abstract intReturns the JDBC type of the key as defined injava.sql.Types.getValue()Get the underlying object.inthashCode()Returns the hashcode of the underlying value (key), if key is not null.setValue(O key) Sets the internal representation to the same object used by key.voidSets the internal representation.toString()Get a String representation of this key.
-
Constructor Details
-
ObjectKey
public ObjectKey()Initializes the internal key value tonull.
-
-
Method Details
-
hashCode
public int hashCode()Returns the hashcode of the underlying value (key), if key is not null. Otherwise calls Object.hashCode() -
equals
Returns whether this ObjekctKey is equal to another Object. obj is equal to this ObjectKey if obj has the same class as this ObjectKey and contains the same information this key contains. Two ObjectKeys that both contain null values are not considered equal. -
getValue
Get the underlying object.- Returns:
- the underlying object
-
getJdbcType
public abstract int getJdbcType()Returns the JDBC type of the key as defined injava.sql.Types.- Returns:
- the JDBC type of the key.
-
appendTo
Appends a String representation of the key to a buffer.- Parameters:
sb- aStringBuilder
-
compareTo
Implements the compareTo method.- Specified by:
compareToin interfaceComparable<T>- Parameters:
obj- the object to compare to this object- Returns:
- a numeric comparison of the two values
-
setValue
Sets the internal representation.- Parameters:
key- the key value
-
setValue
Sets the internal representation to the same object used by key.- Type Parameters:
O- the key type- Parameters:
key- the key value
-
toString
Get a String representation of this key.
-