class: ObjectComparator

public class: ObjectComparator
Author: Miriam Doelle (initial creation)
Project: Phase: 1.0; Status: Proposed; Version: $Revision: 1951 $ $LastChangedDate: 2009-05-07 10:; Complexity: 1
Dates: Created: 16.07.2009 15:13:16; Modified: 16.07.2009 15:13:16;
Flags: Active: false; IsRoot: false; IsLeaf: false;
Extension Points:
UUID: {82A3E873-4438-4eee-B287-267A4B413FE2}
Compares two objects and creates a list of differences.
 

Goto: Custom Properties, Fields, Methods

Appears in: util

Custom Properties
 
ObjectComparator Attributes
Attribute Details
private HashSet
  compared
Initial: new HashSet()
private static const MessageFormat
  DIFFERENT_FIELD_VALUE
Initial: new MessageFormat("Difference in field {1} ({0}): [{2}] [{3}]")
private static const MessageFormat
  DIFFERENT_FIELD_VALUE_IN_LIST
Initial: new MessageFormat("Difference in list element of field {1} ({0}) at position {4}: [{2}] [{3}]")
private static const MessageFormat
  DIFFERENT_LIST_SIZE
Initial: new MessageFormat("Difference in field {1} ({0}): List size [{2}] [{3}]")
private ArrayList
  diffs
Initial: new ArrayList()
private ArrayList
  fieldnames
Initial: new ArrayList()
private static const MessageFormat
  FIRST_VALUE_NULL
Initial: new MessageFormat("First object is null, second object is {0}.")
private static Logger
  logger
Initial: Logger.getLogger(ObjectComparator.class)
private static const MessageFormat
  SECOND_VALUE_NULL
Initial: new MessageFormat("First object is {0}, second object is null.")
 
ObjectComparator Methods
Operation Details
private
checkAllFieldsForClass(
   Class theClass,
   Object o1,
   Object o2):void
Sequential
Tags: throws=IllegalAccessException
private
compareObjects(
   Object fieldValue1,
   Object fieldValue2,
   String fieldname,
   String enclosingClass):void
Sequential
Tags: throws=IllegalAccessException
protected
equals(
   Object obj1,
   Object obj2):boolean
Sequential
Notes: Compares two objects dealing also with null values.
@param o1 The first object to compare.
@param o2 The second object to compare.
@return true if the two objects are equal otherwise false.
public
getDiffs():List
Sequential
Notes: Gets the list of differences between the two objects.
@return the list of differences. If no differences were detected an empty list is returned.
private
getFieldNames():String
Sequential
public
isEqual():boolean
Sequential
Notes: Checks whether the two objects are equal.
@return true if the two objects are equal otherwise false.
private
isSimpleComparableType(
   Object object):boolean
Sequential
public
ObjectComparator(
   Object o1,
   Object o2):
Sequential
Tags: throws=IllegalAccessException
Notes: Creates a new ObjectComparator instance that compares the two given objects. Note: Compare also works with null values.
public
toString():String
Sequential
Notes: Returns a String with one line for each difference.
@return the string represtation of the differences between the compared objects.