Class ObjectUtils
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermine whether the given array is empty: i.e.static booleannullSafeEquals(Object o1, Object o2) Determine if the given objects are equal, returningtrueif both arenullorfalseif only one isnull.static intnullSafeHashCode(boolean[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(byte[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(char[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(double[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(float[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(int[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(long[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(short[] array) Return a hash code based on the contents of the specified array.static intnullSafeHashCode(Object obj) Return as hash code for the given object; typically the value ofObject#hashCode()}.static intnullSafeHashCode(Object[] array) Return a hash code based on the contents of the specified array.static StringnullSafeToString(boolean[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(byte[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(char[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(double[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(float[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(int[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(long[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(short[] array) Return a String representation of the contents of the specified array.static StringnullSafeToString(Object obj) Return a String representation of the specified Object.static StringnullSafeToString(Object[] array) Return a String representation of the contents of the specified array.
-
Constructor Details
-
ObjectUtils
public ObjectUtils()
-
-
Method Details
-
isEmpty
Determine whether the given array is empty: i.e.nullor of zero length.- Parameters:
array- the array to check see #isEmpty(Object)
-
nullSafeEquals
Determine if the given objects are equal, returningtrueif both arenullorfalseif only one isnull.Compares arrays with
Arrays.equals, performing an equality check based on the array elements rather than the array reference.- Parameters:
o1- first Object to compareo2- second Object to compare- Returns:
- whether the given objects are equal see Object#equals(Object) see java.util.Arrays#equals
-
nullSafeHashCode
Return as hash code for the given object; typically the value ofObject#hashCode()}. If the object is an array, this method will delegate to any of thenullSafeHashCodemethods for arrays in this class. If the object isnull, 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
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeHashCode
Return a hash code based on the contents of the specified array. Ifarrayisnull, this method returns 0. -
nullSafeToString
Return a String representation of the specified Object.Builds a String representation of the contents in case of an array. Returns a
"null"String ifobjisnull.- Parameters:
obj- the object to build a String representation for- Returns:
- a String representation of
obj
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-
nullSafeToString
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 ifarrayisnull.- Parameters:
array- the array to build a String representation for- Returns:
- a String representation of
array
-