DeepEquatableUtil

public class DeepEquatableUtil

Some utility methods to use DeepEquals on Collections, as well as null-checking on both.

Author:The Condor

Methods

deepEquals

public static boolean deepEquals(DeepEquatable obj1, DeepEquatable obj2)

A method to compare the deep equality of two DeepEquatable objects.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null of if both are non-null and deepEquals to eachother. False otherwise.

deepEqualsIntList

public static <T> boolean deepEqualsIntList(List<Integer> obj1, List<Integer> obj2)

A method to compare the deep equality of two Lists of Integers.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and objects with the same indices are equals to eachother. False otherwise.

deepEqualsIntSet

public static boolean deepEqualsIntSet(Set<Integer> obj1, Set<Integer> obj2)

A method to compare the deep equality of two Sets of Integer objects.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and each . False otherwise.

deepEqualsList

public static boolean deepEqualsList(List<? extends DeepEquatable> obj1, List<? extends DeepEquatable> obj2)

A method to compare the deep equality of two Lists. Suffixed by List due to type erasure, which makes generics not overload intuitively.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and objects with the same indices are deepEquals to eachother. False otherwise.

deepEqualsListList

public static boolean deepEqualsListList(List<? extends List<? extends DeepEquatable>> obj1, List<? extends List<? extends DeepEquatable>> obj2)

A method to compare the deep equality of two Lists of Lists. Suffixed by ListList due to type erasure, which makes generics not overload intuitively.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and objects with the same indices are deepEquals to eachother. False otherwise.

deepEqualsListMap

public static boolean deepEqualsListMap(List<? extends Map<Integer, ? extends DeepEquatable>> obj1, List<? extends Map<Integer, ? extends DeepEquatable>> obj2)

A method to compare the deep equality of two Lists of Lists. Suffixed by ListList due to type erasure, which makes generics not overload intuitively.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and objects with the same indices are deepEquals to eachother. False otherwise.

deepEqualsMap

public static <T> boolean deepEqualsMap(Map<T, ? extends DeepEquatable> obj1, Map<T, ? extends DeepEquatable> obj2)

A method to compare the deep equality of two Maps. Suffixed by Map for consistancy with others and extensibility.

Parameters:
  • obj1
  • obj2
Returns:

True if both arguments are null or if both are non-null, of the same size, and objects with the same indices are deepEquals to eachother. False otherwise.