Class EqualityUtils


  • public final class EqualityUtils
    extends Object
    This class aggregates common functions to check for equality between objects.
    Author:
    Paulo Zenida - Linkare TI
    • Constructor Detail

      • EqualityUtils

        private EqualityUtils()
        Hiding constructor so that this utility class cannot be instantiated from outside.
    • Method Detail

      • equals

        public static <T> boolean equals​(T object1,
                                         T object2)
        Type Parameters:
        T - the type of the arguments to check for equality. The objects being compared must be of the same type. Therefore, the clients of this method should, explicitly, specify the argument type, something like EqualityUtils.(s1, s2). When that specification is not performed, through the automatic erasure mechanism within Java, the argument type is inferred to the highest class of both arguments (Object, when necessary).
        Parameters:
        object1 - The object to be compared from.
        object2 - The object to be compared to.
        Returns:
        Returns the equality between object1 and object2 where, if object1 is null, then object2 must be null as well. Otherwise, call equals on the object1.