| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | |
| private static final Map | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | Returns: true if the two arrays are the same length and contain deeply equivalent items.[] type (Object[], String[], etc.) array1, Object [] type (Object[], String[], etc.) array2, List<String> the path to the arrays to compare path, Deque<DeepDifference.add items to compare to the Stack (Stack versus recursion) toCompare,Set of objects already compared (prevents cycles) visitedDeeply compare to Arrays []. |
| private static < the key type K, the value type V> boolean | Returns: boolean false if the Collections are for certain not equalsFirst collection of items to compare col1, Collection<V> Second collection of items to compare col2, List<String> The path to the collections path, Deque<DeepDifference.add items to compare to the Stack (Stack versus recursion) toCompare,Set of objects already compared (prevents cycles) value of
'true' indicates that the Collections may be equal, and the
sets items will be added to the Stack for further comparison. visitedDeeply compare two Collections that must be same length and in same order. |
| private static < the first key type K1, the first value type V1, the second key type K2, the second value type V2> boolean | Returns: false if the Maps are for certain not equals. 'true' indicates that 'on the surface' the maps are equal, however, it will place the contents of the Maps on the stack for further comparisons.SortedMap one map1, SortedMap<K2, V2> SortedMap two map2, List<String> the path to the maps to compare path, Deque<DeepDifference.add items to compare to the Stack (Stack versus recursion) toCompare,Set containing items that have already been compared, to
prevent cycles. visitedDeeply compare two SortedMap instances. |
| private static <K, V> boolean | compareUnorderedCollection(Collection<K> col1, Collection<V> col2, List<String> path, Deque<DeepDifference.
|
| private static < the key type K, the value type V> boolean | Returns: boolean false if the Collections are for certain not equals. A value of 'true' indicates that the Collections may be equal, and the sets items will be added to the Stack for further comparison.First collection of items to compare col1, Collection<V> Second collection of items to compare col2, List<String> the path to the collections to compare path, Deque<DeepDifference.add items to compare to the Stack (Stack versus recursion) toCompare,Set containing items that have already been compared, so as to
prevent cycles. visitedIt places one collection into a temporary Map by deepHashCode(), so that it can walk the other collection and look for each item in the map, which runs in O(N) time, rather than an O(N^2) lookup that would occur if each item from collection one was scanned for in collection two. |
| private static < the first key type K1, the first value type V1, the second key type K2, the second value type V2> boolean | Returns: false if the Maps are for certain not equals. 'true' indicates that 'on the surface' the maps are equal, however, it will place the contents of the Maps on the stack for further comparisons.Map one map1, Map<K2, V2> Map two map2, List<String> the path to the maps to compare path, Deque<DeepDifference.add items to compare to the Stack (Stack versus recursion) toCompare,Set containing items that have already been compared, to
prevent cycles. visitedDeeply compare two Map instances. |
| pack-priv static int | Returns: the 'deep' hashCode value for the passed in object.Object who hashCode is desired. obj)Get a deterministic hashCode (int) value for an Object, regardless of when it was created or where it was loaded into memory. |
| public static List | Returns: the list of differences found or an empty list if objects are equivalent. Equivalent means that all field values of both subgraphs are the same, either at the field level or via the respectively encountered overridden .equals() methods during traversal.Object one to compare a, Object Object two to compare b, Map<String, Comparator<?>> comparators to compare properties or fields with the given names comparatorByPropertyOrField, TypeComparators comparators to compare properties or fields with the given types comparatorByType)Compare two objects for differences by doing a 'deep' comparison. |
| private static List | determineDifferences(Object a, Object b, List<String> parentPath, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType)
|
| private static Set | |
| private static boolean | hasCustomComparator(DeepDifference.
|
| pack-priv static boolean | Returns: true, if the passed in Class has a .equals() method somewhere between itself and just below Object in it's inheritance.Class to check. c)Determine if the passed in class has a non-Object.equals() method. |
| pack-priv static boolean | Returns: true, if the passed in Class has a .hashCode() method somewhere between itself and just below Object in it's inheritance.Class to check. c)Determine if the passed in class has a non-Object.hashCode() method. |
| private static Deque | initStack(Object a, Object b, List<String> parentPath, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType)
|
| private static boolean |
| customEquals | back to summary |
|---|---|
| private static final Map<Class<?>, Boolean> customEquals | |
| customHash | back to summary |
|---|---|
| private static final Map<Class<?>, Boolean> customHash | |
| MISSING_FIELDS | back to summary |
|---|---|
| private static final String MISSING_FIELDS | |
| DeepDifference | back to summary |
|---|---|
| public DeepDifference() | |
| compareArrays | back to summary |
|---|---|
| private static boolean compareArrays(Object array1, Object array2, List<String> path, Deque<DeepDifference. Deeply compare to Arrays []. Both arrays must be of the same type, same length, and all elements within the arrays must be deeply equal in order to return true.
| |
| compareOrderedCollection | back to summary |
|---|---|
| private static <K, V> boolean compareOrderedCollection(Collection<K> col1, Collection<V> col2, List<String> path, Deque<DeepDifference. Deeply compare two Collections that must be same length and in same order.
| |
| compareSortedMap | back to summary |
|---|---|
| private static <K1, V1, K2, V2> boolean compareSortedMap(SortedMap<K1, V1> map1, SortedMap<K2, V2> map2, List<String> path, Deque<DeepDifference. Deeply compare two SortedMap instances. This method walks the Maps in order, taking advantage of the fact that the Maps are SortedMaps.
| |
| compareUnorderedCollection | back to summary |
|---|---|
| private static <K, V> boolean compareUnorderedCollection(Collection<K> col1, Collection<V> col2, List<String> path, Deque<DeepDifference. | |
| compareUnorderedCollectionByHashCodes | back to summary |
|---|---|
| private static <K, V> boolean compareUnorderedCollectionByHashCodes(Collection<K> col1, Collection<V> col2, List<String> path, Deque<DeepDifference. It places one collection into a temporary Map by deepHashCode(), so that it can walk the other collection and look for each item in the map, which runs in O(N) time, rather than an O(N^2) lookup that would occur if each item from collection one was scanned for in collection two.
| |
| compareUnorderedMap | back to summary |
|---|---|
| private static <K1, V1, K2, V2> boolean compareUnorderedMap(Map<K1, V1> map1, Map<K2, V2> map2, List<String> path, Deque<DeepDifference. Deeply compare two Map instances. After quick short-circuit tests, this method uses a temporary Map so that this method can run in O(N) time.
| |
| deepHashCode | back to summary |
|---|---|
| pack-priv static int deepHashCode(Object obj) Get a deterministic hashCode (int) value for an Object, regardless of
when it was created or where it was loaded into memory. The problem with
java.lang.Object.hashCode() is that it essentially relies on memory
location of an object (what identity it was assigned), whereas this
method will produce the same hashCode for any object graph, regardless of
how many times it is created.
| |
| determineDifferences | back to summary |
|---|---|
| public static List Compare two objects for differences by doing a 'deep' comparison. This will traverse the Object graph and perform either a field-by-field comparison on each object (if not .equals() method has been overridden from Object), or it will call the customized .equals() method if it exists. This method handles cycles correctly, for example A->B->C->A. Suppose a and a' are two separate instances of the A with the same values for all fields on A, B, and C. Then a.deepEquals(a') will return an empty list. It uses cycle detection storing visited objects in a Set to prevent endless loops.
| |
| determineDifferences | back to summary |
|---|---|
| private static List | |
| getFieldsNames | back to summary |
|---|---|
| private static Set | |
| hasCustomComparator | back to summary |
|---|---|
| private static boolean hasCustomComparator(DeepDifference. | |
| hasCustomEquals | back to summary |
|---|---|
| pack-priv static boolean hasCustomEquals(Class<?> c) Determine if the passed in class has a non-Object.equals() method. This method caches its results in static ConcurrentHashMap to benefit execution performance.
| |
| hasCustomHashCode | back to summary |
|---|---|
| pack-priv static boolean hasCustomHashCode(Class<?> c) Determine if the passed in class has a non-Object.hashCode() method. This method caches its results in static ConcurrentHashMap to benefit execution performance.
| |
| initStack | back to summary |
|---|---|
| private static Deque | |
| isContainerType | back to summary |
|---|---|
| private static boolean isContainerType(Object o) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Object | |
| pack-priv Optional | |
| pack-priv Object | |
| pack-priv List |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | |
| public Optional | |
| public Object | |
| public List | |
| public String |
| actual | back to summary |
|---|---|
| pack-priv Object actual | |
| description | back to summary |
|---|---|
| pack-priv Optional<String> description | |
| other | back to summary |
|---|---|
| pack-priv Object other | |
| path | back to summary |
|---|---|
| pack-priv List<String> path | |
| Difference | back to summary |
|---|---|
| public Difference(List<String> path, Object actual, Object other) | |
| Difference | back to summary |
|---|---|
| public Difference(List<String> path, Object actual, Object other, String description) | |
| getActual | back to summary |
|---|---|
| public Object getActual() | |
| getDescription | back to summary |
|---|---|
| public Optional | |
| getOther | back to summary |
|---|---|
| public Object getOther() | |
| getPath | back to summary |
|---|---|
| public List | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Object | |
| private final Object | |
| private final List |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public String | |
| public List | |
| public int | |
| public String |
| key1 | back to summary |
|---|---|
| private final Object key1 | |
| key2 | back to summary |
|---|---|
| private final Object key2 | |
| path | back to summary |
|---|---|
| private final List<String> path | |
| DualKey | back to summary |
|---|---|
| private DualKey(List<String> path, Object key1, Object key2) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getConcatenatedPath | back to summary |
|---|---|
| public String getConcatenatedPath() | |
| getPath | back to summary |
|---|---|
| public List | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |