ix.util
Class StructuralEquality

java.lang.Object
  extended by ix.util.StructuralEquality
Direct Known Subclasses:
SerializationTest.StrictEquality

public class StructuralEquality
extends java.lang.Object

Compares two objects to see whether they have the same values in the same places. This is simpler than a Comparator, because it doesn't have to determine which of two unequal objects is the greater. However, what counts as the same value, or the same place, might very, so that more than one class of this sort could be defined. Another variation could be the ability to handle circularities.

This class


Nested Class Summary
static class StructuralEquality.IncomparableException
           
 
Field Summary
protected  ClassSyntax syntax
           
 
Constructor Summary
StructuralEquality()
          Creates an equality test that used the default ClassSyntax.
StructuralEquality(ClassSyntax syntax)
          Creates an equality test that uses the specified ClassSyntax as a source for ClassDescrs.
 
Method Summary
 boolean equal(java.lang.Object a, java.lang.Object b)
          Compares two objects, returning true if they are structurally equal and false otherwise.
protected  boolean equalLists(java.util.List a, java.util.List b)
           
protected  boolean equalMaps(java.util.Map a, java.util.Map b)
           
protected  boolean equalSets(java.util.Set a, java.util.Set b)
           
protected  boolean equalStructs(java.lang.Object a, java.lang.Object b, ClassDescr cd)
           
protected  boolean haveEquivalentClasses(java.lang.Object a, java.lang.Object b)
           
protected  boolean missingFieldIsOk(ClassDescr cd, FieldDescr fd, java.lang.Object f_a, java.lang.Object f_b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

syntax

protected ClassSyntax syntax
Constructor Detail

StructuralEquality

public StructuralEquality()
Creates an equality test that used the default ClassSyntax.

See Also:
XML

StructuralEquality

public StructuralEquality(ClassSyntax syntax)
Creates an equality test that uses the specified ClassSyntax as a source for ClassDescrs.

Method Detail

equal

public boolean equal(java.lang.Object a,
                     java.lang.Object b)
Compares two objects, returning true if they are structurally equal and false otherwise.

Throws:
StructuralEquality.IncomparableException - if a comparison of corresponding parts of the two objects that should be possible cannot be performed.

haveEquivalentClasses

protected boolean haveEquivalentClasses(java.lang.Object a,
                                        java.lang.Object b)

equalLists

protected boolean equalLists(java.util.List a,
                             java.util.List b)

equalSets

protected boolean equalSets(java.util.Set a,
                            java.util.Set b)

equalMaps

protected boolean equalMaps(java.util.Map a,
                            java.util.Map b)

equalStructs

protected boolean equalStructs(java.lang.Object a,
                               java.lang.Object b,
                               ClassDescr cd)

missingFieldIsOk

protected boolean missingFieldIsOk(ClassDescr cd,
                                   FieldDescr fd,
                                   java.lang.Object f_a,
                                   java.lang.Object f_b)