Class ObjectUtil


  • public class ObjectUtil
    extends Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean nullSafeEquals​(Object o1, Object o2)
      Determine if the given objects are equal, returning true if both are null or false if only one is null.
      static int nullSafeHashCode​(boolean[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(byte[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(char[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(double[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(float[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(int[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(long[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(short[] array)
      Return a hash code based on the contents of the specified array.
      static int nullSafeHashCode​(Object obj)
      Return as hash code for the given object; typically the value of Object#hashCode()}.
      static int nullSafeHashCode​(Object[] array)
      Return a hash code based on the contents of the specified array.
    • Method Detail

      • nullSafeEquals

        public static boolean nullSafeEquals​(Object o1,
                                             Object o2)
        Determine if the given objects are equal, returning true if both are null or false if only one is null.

        Compares arrays with Arrays.equals, performing an equality check based on the array elements rather than the array reference.

        Parameters:
        o1 - first Object to compare
        o2 - second Object to compare
        Returns:
        whether the given objects are equal
        See Also:
        Object.equals(Object), Arrays.equals(long[], long[])
      • nullSafeHashCode

        public static int nullSafeHashCode​(Object[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(boolean[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(byte[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(char[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(double[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(float[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(int[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(long[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
      • nullSafeHashCode

        public static int nullSafeHashCode​(short[] array)
        Return a hash code based on the contents of the specified array. If array is null, this method returns 0.