jdsl.core.ref
Class ObjectHashComparator
java.lang.Object
|
+--jdsl.core.ref.ObjectHashComparator
- All Implemented Interfaces:
- EqualityComparator, HashComparator
- public class ObjectHashComparator
- extends java.lang.Object
- implements HashComparator
Implements the JDSL HashComparator interface in terms of Java's
native Object methods equals(.) and hashCode().
- Version:
- $Revision: 1.3 $, $Date: 2000/01/12 03:21:43 $
- Author:
- Keith Schmidt (kas)
Method Summary |
int |
hashValue(java.lang.Object o)
Returns the hash code value to be used for the object in this
comparator. |
boolean |
isComparable(java.lang.Object o)
Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined. |
boolean |
isEqualTo(java.lang.Object x1,
java.lang.Object x2)
returns x1.equals(x2) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ObjectHashComparator
public ObjectHashComparator()
isComparable
public boolean isComparable(java.lang.Object o)
- Description copied from interface:
EqualityComparator
- Allows a container (or any client) to find out whether an object is
a member of the ordered set over which this comparator is defined.
- Specified by:
isComparable
in interface EqualityComparator
- Parameters:
o
- Object you propose to compare with this comparator- Returns:
- Whether o is non-null
isEqualTo
public boolean isEqualTo(java.lang.Object x1,
java.lang.Object x2)
throws java.lang.ClassCastException
- returns x1.equals(x2)
- Specified by:
isEqualTo
in interface EqualityComparator
- Parameters:
x1
- the reference object in the comparison.x2
- the object tested against the reference object.- Returns:
- whether x1 is equal to x2
hashValue
public int hashValue(java.lang.Object o)
- Description copied from interface:
HashComparator
- Returns the hash code value to be used for the object in this
comparator.
It is expected that hashValue will return a non-negative integer
as the hashcode of the Object, as is the custom for hashcodes.
However, there are no unsigned types to force this.
- Specified by:
hashValue
in interface HashComparator
- Parameters:
o
- Object for which you desire a hash value- Returns:
- a non-negative integer hash value