Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.util
Class StructuralEquality

    java.lang.Object
      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

- Requires that equal objects be of exactly the same class.
- Allows elements to appear in different orders when comparing Sets or Maps.
- Uses a `ClassSyntax` to determine which fields to compare in structures.
- Doesn't handle arrays.

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 `ClassDescr`s.

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)`

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 `ClassDescr`s.

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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD