org.unitils.reflectionassert.comparator.impl
Class SimpleCasesComparator

java.lang.Object
  extended by org.unitils.reflectionassert.comparator.impl.SimpleCasesComparator
All Implemented Interfaces:
Comparator

public class SimpleCasesComparator
extends Object
implements Comparator

Comparator for simple cases. Following cases are handled: left and right are the same instance, left or right have a null value, left or right are enumerations, left or right are java.lang classes and left or right are of type Character or Number

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
SimpleCasesComparator()
           
 
Method Summary
 boolean canCompare(Object left, Object right)
          Returns true if both object are the same instance, have a null value, are an Enum/Number/Character or are a java.lang type.
 Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator)
          Compares the given values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCasesComparator

public SimpleCasesComparator()
Method Detail

canCompare

public boolean canCompare(Object left,
                          Object right)
Returns true if both object are the same instance, have a null value, are an Enum/Number/Character or are a java.lang type.

Specified by:
canCompare in interface Comparator
Parameters:
left - The left object
right - The right object
Returns:
True for simple cases

compare

public Difference compare(Object left,
                          Object right,
                          boolean onlyFirstDifference,
                          ReflectionComparator reflectionComparator)
Compares the given values.

Specified by:
compare in interface Comparator
Parameters:
left - The left value
right - The right value
onlyFirstDifference - True if only the first difference should be returned
reflectionComparator - The root comparator for inner comparisons, not null
Returns:
A Difference if both values are different, null otherwise


Copyright © 2011. All Rights Reserved.