Class CompareUtil


  • public class CompareUtil
    extends Object
    Utility class containing static comparison methods.
    • Method Detail

      • equals

        public static boolean equals​(Object o1,
                                     Object o2)
        Compares two objects for equality.
        Parameters:
        o1 - Object
        o2 - Object
        Returns:
        whether o1 and o2 are equal
      • equals

        public static boolean equals​(Object[] o1,
                                     Object[] o2)
        Compares two arrays of objects for equality.
        Parameters:
        o1 - Object array
        o2 - Object array
        Returns:
        whether o1 and o2 are equal
      • equals

        public static boolean equals​(byte[] o1,
                                     byte[] o2)
        Compares two byte arrays for equality.
        Parameters:
        o1 - byte array
        o2 - byte array
        Returns:
        whether o1 and o2 are equal
      • equals

        public static boolean equals​(int[] o1,
                                     int[] o2)
        Compares two int arrays for equality.
        Parameters:
        o1 - int array
        o2 - int array
        Returns:
        whether o1 and o2 are equal
      • compare

        public static <T> int compare​(Comparable<T> c1,
                                      T c2)
        Compares two objects for relative order. Null values are ordered before (ie. considered smaller than) non-null values.
        Type Parameters:
        T - type of objects.
        Parameters:
        c1 - Object that implements Comparable
        c2 - Object
        Returns:
        -1, 0, or 1 depending if c1 is less than, equal, or greater than c2.