org.unitils.reflectionassert.report.impl
Class TreeDifferenceView

java.lang.Object
  extended by org.unitils.reflectionassert.report.impl.TreeDifferenceView
All Implemented Interfaces:
DifferenceView

public class TreeDifferenceView
extends Object
implements DifferenceView

Formatter that will output all objects in the difference tree. For an unordered collection difference, the best matching differences are taken.

Author:
Tim Ducheyne, Filip Neven

Nested Class Summary
protected  class TreeDifferenceView.TreeDifferenceFormatterVisitor
          The visitor for visiting the difference tree.
 
Field Summary
protected  ObjectFormatter objectFormatter
          Formatter for object values.
protected  TreeDifferenceView.TreeDifferenceFormatterVisitor treeDifferenceFormatterVisitor
          The visitor for visiting the difference tree
 
Constructor Summary
TreeDifferenceView()
           
 
Method Summary
protected  String createFieldName(String fieldName, String innerFieldName, boolean includePoint)
          Adds the inner field name to the given field name.
 String createView(Difference difference)
          Creates a string representation of the given difference tree.
protected  String formatDifference(ClassDifference classDifference, String fieldName)
           
protected  String formatDifference(CollectionDifference collectionDifference, String fieldName)
          Creates a string representation of a collection difference.
protected  String formatDifference(Difference difference, String fieldName)
          Creates a string representation of a simple difference.
protected  String formatDifference(MapDifference mapDifference, String fieldName)
          Creates a string representation of a map difference.
protected  String formatDifference(ObjectDifference objectDifference, String fieldName)
          Creates a string representation of an object difference.
protected  String formatDifference(UnorderedCollectionDifference unorderedCollectionDifference, String fieldName)
          Creates a string representation of an unorder collection difference.
protected  String formatObject(Object object)
           
protected  String formatValues(String fieldName, Object leftValue, Object rightValue)
          Formats and appends the given fieldname and object values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectFormatter

protected ObjectFormatter objectFormatter
Formatter for object values.


treeDifferenceFormatterVisitor

protected TreeDifferenceView.TreeDifferenceFormatterVisitor treeDifferenceFormatterVisitor
The visitor for visiting the difference tree

Constructor Detail

TreeDifferenceView

public TreeDifferenceView()
Method Detail

createView

public String createView(Difference difference)
Creates a string representation of the given difference tree.

Specified by:
createView in interface DifferenceView
Parameters:
difference - The root difference, not null
Returns:
The string representation, not null

formatDifference

protected String formatDifference(Difference difference,
                                  String fieldName)
Creates a string representation of a simple difference.

Parameters:
difference - The difference, not null
fieldName - The current fieldName, null for root
Returns:
The string representation, not null

formatDifference

protected String formatDifference(ObjectDifference objectDifference,
                                  String fieldName)
Creates a string representation of an object difference.

Parameters:
objectDifference - The difference, not null
fieldName - The current fieldName, null for root
Returns:
The string representation, not null

formatDifference

protected String formatDifference(ClassDifference classDifference,
                                  String fieldName)

formatDifference

protected String formatDifference(CollectionDifference collectionDifference,
                                  String fieldName)
Creates a string representation of a collection difference.

Parameters:
collectionDifference - The difference, not null
fieldName - The current fieldName, null for root
Returns:
The string representation, not null

formatDifference

protected String formatDifference(MapDifference mapDifference,
                                  String fieldName)
Creates a string representation of a map difference.

Parameters:
mapDifference - The difference, not null
fieldName - The current fieldName, null for root
Returns:
The string representation, not null

formatObject

protected String formatObject(Object object)

formatDifference

protected String formatDifference(UnorderedCollectionDifference unorderedCollectionDifference,
                                  String fieldName)
Creates a string representation of an unorder collection difference.

Parameters:
unorderedCollectionDifference - The difference, not null
fieldName - The current fieldName, null for root
Returns:
The string representation, not null

formatValues

protected String formatValues(String fieldName,
                              Object leftValue,
                              Object rightValue)
Formats and appends the given fieldname and object values.

Parameters:
fieldName - The field name, null if there is no field name
leftValue - The left value
rightValue - The right value
Returns:
The string representation, not null

createFieldName

protected String createFieldName(String fieldName,
                                 String innerFieldName,
                                 boolean includePoint)
Adds the inner field name to the given field name.

Parameters:
fieldName - The field
innerFieldName - The field to append, not null
includePoint - True if a point should be added
Returns:
The field name


Copyright © 2011. All Rights Reserved.