org.unitils.reflectionassert.comparator.impl
Class IgnoreDefaultsComparator

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

public class IgnoreDefaultsComparator
extends Object
implements Comparator

A comparator that filters out java-defaults. If the left object is null, false or 0, both objects are considered equal. This implements the IGNORE_DEFAULTS comparison mode.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
IgnoreDefaultsComparator()
           
 
Method Summary
 boolean canCompare(Object left, Object right)
          Returns true if the left object is a java default
 Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator)
          Always returns null: both objects are equal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IgnoreDefaultsComparator

public IgnoreDefaultsComparator()
Method Detail

canCompare

public boolean canCompare(Object left,
                          Object right)
Returns true if the left object is a java default

Specified by:
canCompare in interface Comparator
Parameters:
left - The left object
right - The right object
Returns:
True if left is null, false or 0

compare

public Difference compare(Object left,
                          Object right,
                          boolean onlyFirstDifference,
                          ReflectionComparator reflectionComparator)
Always returns null: both objects are equal.

Specified by:
compare in interface Comparator
Parameters:
left - The left object
right - The right object
onlyFirstDifference - True if only the first difference should be returned
reflectionComparator - The root comparator for inner comparisons, not null
Returns:
null


Copyright © 2011. All Rights Reserved.