org.oddjob.beancmpr.comparers
Class EqualityComparer

java.lang.Object
  extended by org.oddjob.beancmpr.comparers.EqualityComparer
All Implemented Interfaces:
Comparer<Object>

public class EqualityComparer
extends Object
implements Comparer<Object>

A comparer that uses the equals method of an object.

If either or both of the objects are null the result of the compare will be null.

Author:
rob

Constructor Summary
EqualityComparer()
           
 
Method Summary
 Comparison<Object> compare(Object x, Object y)
          Compare two things.
 Class<Object> getType()
          The type of the things.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EqualityComparer

public EqualityComparer()
Method Detail

compare

public Comparison<Object> compare(Object x,
                                  Object y)
Description copied from interface: Comparer
Compare two things.

Specified by:
compare in interface Comparer<Object>
Parameters:
x - One thing.
y - The other thing.
Returns:
A Comparison. The may be null if either or both of x and y is null.

getType

public Class<Object> getType()
Description copied from interface: Comparer
The type of the things.

Note that we would have liked the return type to be Class<T> but we could not then have had a Comparer<Iterable<MatchableGroup>> because it's not possible to return a type of Class<Iterable<MatchableGroup>> in Java. If there is a solution to this then please let us know.

Specified by:
getType in interface Comparer<Object>
Returns:
The type. Must not be null.


Copyright © 2013. All Rights Reserved.