java.lang.Object
nl.basjes.parse.useragent.utils.springframework.util.ObjectUtils

public abstract class ObjectUtils extends Object
Miscellaneous object utility methods.

Mainly for internal use within the framework.

Thanks to Alex Ruiz for contributing several enhancements to this class!

Since:
19.03.2004
Author:
Juergen Hoeller, Keith Donald, Rod Johnson, Rob Harrop, Chris Beams, Sam Brannen see ClassUtils see CollectionUtils see StringUtils
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isEmpty(Object[] array)
    Determine whether the given array is empty: i.e.
    static boolean
    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
    Return as hash code for the given object; typically the value of Object#hashCode()}.
    static int
    Return a hash code based on the contents of the specified array.
    static String
    nullSafeToString(boolean[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(byte[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(char[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(double[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(float[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(int[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(long[] array)
    Return a String representation of the contents of the specified array.
    static String
    nullSafeToString(short[] array)
    Return a String representation of the contents of the specified array.
    static String
    Return a String representation of the specified Object.
    static String
    Return a String representation of the contents of the specified array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ObjectUtils

      public ObjectUtils()
  • Method Details

    • isEmpty

      public static boolean isEmpty(@Nullable Object[] array)
      Determine whether the given array is empty: i.e. null or of zero length.
      Parameters:
      array - the array to check see #isEmpty(Object)
    • nullSafeEquals

      public static boolean nullSafeEquals(@Nullable Object o1, @Nullable 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 Object#equals(Object) see java.util.Arrays#equals
    • nullSafeHashCode

      public static int nullSafeHashCode(@Nullable Object obj)
      Return as hash code for the given object; typically the value of Object#hashCode()}. If the object is an array, this method will delegate to any of the nullSafeHashCode methods for arrays in this class. If the object is null, this method returns 0. see Object#hashCode() see #nullSafeHashCode(Object[]) see #nullSafeHashCode(boolean[]) see #nullSafeHashCode(byte[]) see #nullSafeHashCode(char[]) see #nullSafeHashCode(double[]) see #nullSafeHashCode(float[]) see #nullSafeHashCode(int[]) see #nullSafeHashCode(long[]) see #nullSafeHashCode(short[])
    • nullSafeHashCode

      public static int nullSafeHashCode(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable short[] array)
      Return a hash code based on the contents of the specified array. If array is null, this method returns 0.
    • nullSafeToString

      public static String nullSafeToString(@Nullable Object obj)
      Return a String representation of the specified Object.

      Builds a String representation of the contents in case of an array. Returns a "null" String if obj is null.

      Parameters:
      obj - the object to build a String representation for
      Returns:
      a String representation of obj
    • nullSafeToString

      public static String nullSafeToString(@Nullable Object[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable boolean[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable byte[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable char[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable double[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable float[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable int[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable long[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array
    • nullSafeToString

      public static String nullSafeToString(@Nullable short[] array)
      Return a String representation of the contents of the specified array.

      The String representation consists of a list of the array's elements, enclosed in curly braces ("{}"). Adjacent elements are separated by the characters ", " (a comma followed by a space). Returns a "null" String if array is null.

      Parameters:
      array - the array to build a String representation for
      Returns:
      a String representation of array