org.jjoost.util
Class Equalities.RehashingEquality<V>

java.lang.Object
  extended by org.jjoost.util.Equalities.RehashingEquality<V>
All Implemented Interfaces:
java.io.Serializable, Equality<V>
Enclosing class:
Equalities

public static final class Equalities.RehashingEquality<V>
extends java.lang.Object
implements Equality<V>

an Equality which delegates to the provided Equality, but passes the resulting hash() through the provided Rehasher before returning it

Author:
b.elliottsmith
See Also:
Serialized Form

Constructor Summary
Equalities.RehashingEquality(Equality<V> delegate, Rehasher rehasher)
          Create a new RehashingEquality
 
Method Summary
 boolean equates(V a, V b)
          Returns a boolean indicating if the two parameters are considered equal by this Equality
 int hash(V o)
          Returns the hash value of the object as defined by this Equality.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Equalities.RehashingEquality

public Equalities.RehashingEquality(Equality<V> delegate,
                                    Rehasher rehasher)
Create a new RehashingEquality

Parameters:
delegate - the Equality to delegate to
rehasher - the Rehasher to pass the hash through
Method Detail

hash

public int hash(V o)
Description copied from interface: Equality
Returns the hash value of the object as defined by this Equality. For all objects this Equality can be applied to, it should be the case that equates(a, b) ==> hash(a) == hash(b)

Specified by:
hash in interface Equality<V>
Parameters:
o - an Object of type E
Returns:
the hash of the parameter

equates

public boolean equates(V a,
                       V b)
Description copied from interface: Equality
Returns a boolean indicating if the two parameters are considered equal by this Equality

Specified by:
equates in interface Equality<V>
Parameters:
a - an Object of type E
b - another Object of type E
Returns:
true if this equality equates the two arguments