org.unitils.reflectionassert.difference
Class ObjectDifference

java.lang.Object
  extended by org.unitils.reflectionassert.difference.Difference
      extended by org.unitils.reflectionassert.difference.ObjectDifference

public class ObjectDifference
extends Difference

A class for holding the difference between two objects.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
ObjectDifference(String message, Object leftValue, Object rightValue)
          Creates a difference.
 
Method Summary
<T,A> T
accept(DifferenceVisitor<T,A> visitor, A argument)
          Double dispatch method.
 void addFieldDifference(String fieldName, Difference difference)
          Adds a difference for the field with the given name.
 Map<String,Difference> getFieldDifferences()
          Gets all differences per field name.
 
Methods inherited from class org.unitils.reflectionassert.difference.Difference
getLeftValue, getMessage, getRightValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectDifference

public ObjectDifference(String message,
                        Object leftValue,
                        Object rightValue)
Creates a difference.

Parameters:
message - a message describing the difference
leftValue - the left instance
rightValue - the right instance
Method Detail

addFieldDifference

public void addFieldDifference(String fieldName,
                               Difference difference)
Adds a difference for the field with the given name.

Parameters:
fieldName - The field name, not null
difference - The difference, not null

getFieldDifferences

public Map<String,Difference> getFieldDifferences()
Gets all differences per field name.

Returns:
The differences, not null

accept

public <T,A> T accept(DifferenceVisitor<T,A> visitor,
                      A argument)
Double dispatch method. Dispatches back to the given visitor.

All subclasses should copy this method in their own class body.

Overrides:
accept in class Difference
Parameters:
visitor - The visitor, not null
argument - An optional argument for the visitor, null if not applicable
Returns:
The result


Copyright © 2011. All Rights Reserved.