java.lang.Object | |
↳ | org.springframework.util.ObjectUtils |
Miscellaneous object utility methods.
Mainly for internal use within the framework; consider Jakarta's Commons Lang for a more comprehensive suite of object utilities.
Thanks to Alex Ruiz for contributing several enhancements to this class!
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Append the given object to the given array, returning a new array
consisting of the input array contents plus the given object.
| |||||||||||
Case insensitive alternative to
valueOf(Class, String) . | |||||||||||
Check whether the given array of enum constants contains a constant with the given name.
| |||||||||||
Check whether the given array of enum constants contains a constant with the given name,
ignoring case when determining a match.
| |||||||||||
Check whether the given array contains the given element.
| |||||||||||
Return a content-based String representation if
obj is
not null ; otherwise returns an empty String. | |||||||||||
Return a hex String form of an object's identity hash code.
| |||||||||||
Return the same value as
. | |||||||||||
Return the same value as
. | |||||||||||
Return the same value as
. | |||||||||||
Return the same value as
. | |||||||||||
Return a String representation of an object's overall identity.
| |||||||||||
Determine whether the given object is an array:
either an Object array or a primitive array.
| |||||||||||
Return whether the given throwable is a checked exception:
that is, neither a RuntimeException nor an Error.
| |||||||||||
Check whether the given exception is compatible with the exceptions
declared in a throws clause.
| |||||||||||
Determine whether the given array is empty:
i.e.
| |||||||||||
Determine the class name for the given object.
| |||||||||||
Determine if the given objects are equal, returning
true
if both are null or false if only one is
null . | |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return as hash code for the given object; typically the value of
. | |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a hash code based on the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the contents of the specified array.
| |||||||||||
Return a String representation of the specified Object.
| |||||||||||
Convert the given array (which may be a primitive array) to an
object array (if necessary of primitive wrapper objects).
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Append the given object to the given array, returning a new array consisting of the input array contents plus the given object.
array | the array to append to (can be null ) |
---|---|
obj | the object to append |
null
)
Case insensitive alternative to valueOf(Class, String)
.
enumValues | the array of all Enum constants in question, usually per Enum.values() |
---|---|
constant | the constant to get the enum value of |
IllegalArgumentException | if the given constant is not found in the given array
of enum values. Use containsConstant(Enum[], String) as a guard to avoid this exception.
|
---|
Check whether the given array of enum constants contains a constant with the given name.
enumValues | the enum values to check, typically the product of a call to MyEnum.values() |
---|---|
constant | the constant name to find (must not be null or empty string) |
caseSensitive | whether case is significant in determining a match |
Check whether the given array of enum constants contains a constant with the given name, ignoring case when determining a match.
enumValues | the enum values to check, typically the product of a call to MyEnum.values() |
---|---|
constant | the constant name to find (must not be null or empty string) |
Check whether the given array contains the given element.
array | the array to check (may be null ,
in which case the return value will always be false ) |
---|---|
element | the element to check for |
Return a content-based String representation if obj
is
not null
; otherwise returns an empty String.
Differs from nullSafeToString(Object)
in that it returns
an empty String rather than "null" for a null
value.
obj | the object to build a display String for |
---|
obj
Return a hex String form of an object's identity hash code.
obj | the object |
---|
Return the same value as
.hashCode()
Return the same value as
.hashCode()
Return the same value as
.hashCode()
Return the same value as
.hashCode()
Return a String representation of an object's overall identity.
obj | the object (may be null ) |
---|
null
Determine whether the given object is an array: either an Object array or a primitive array.
obj | the object to check |
---|
Return whether the given throwable is a checked exception: that is, neither a RuntimeException nor an Error.
ex | the throwable to check |
---|
Exception
RuntimeException
Check whether the given exception is compatible with the exceptions declared in a throws clause.
ex | the exception to checked |
---|---|
declaredExceptions | the exceptions declared in the throws clause |
Determine whether the given array is empty:
i.e. null
or of zero length.
array | the array to check |
---|
Determine the class name for the given object.
Returns "null"
if obj
is null
.
obj | the object to introspect (may be null ) |
---|
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.
o1 | first Object to compare |
---|---|
o2 | second Object to compare |
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return as hash code for the given object; typically the value of
. If the object is an array,
this method will delegate to any of the hashCode()
nullSafeHashCode
methods for arrays in this class. If the object is null
,
this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
Return a hash code based on the contents of the specified array.
If array
is null
, this method returns 0.
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
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
"null"
if array
is null
.
array | the array to build a String representation for |
---|
array
Return a String representation of the specified Object.
Builds a String representation of the contents in case of an array.
Returns "null"
if obj
is null
.
obj | the object to build a String representation for |
---|
obj
Convert the given array (which may be a primitive array) to an object array (if necessary of primitive wrapper objects).
A null
source value will be converted to an
empty Object array.
source | the (potentially primitive) array |
---|
null
)IllegalArgumentException | if the parameter is not an array |
---|