Object.
This class tries to handle null input gracefully.
An exception will generally not be thrown for a null input.
Each method documents its behavior in more detail.
#ThreadSafe#
Consumers, Suppliers
| Modifier and Type | Class and Description |
|---|---|
| public static class | ObjectUtils.
Class used as a null placeholder where |
| Modifier and Type | Field and Description |
|---|---|
| private static final char | |
| public static final ObjectUtils. | NULL
Singleton used as a |
| Access | Constructor and Description |
|---|---|
| public | ObjectUtils()
Deprecated
TODO Make private in 4.0.
|
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: false if there is at least one null value in the array or the array is null, true if all values in the array are
not nulls or array contains no elements.the values to test, may be values)null or empty.Tests if all values in the array are not |
| public static boolean | |
| public static boolean | Returns: true if there is at least one non-null value in the array, false if all values in the array are nulls. If the array is
null or empty false is also returned.the values to test, may be values)null or empty.Tests if any value in the given array is not |
| public static boolean | |
| public static < the type of the object. T> T | |
| public static < the type of the object. T> T | Returns: the clone if the object implementsCloneable otherwise the object itself.the object to clone, null returns null. obj)Clones an object if possible. |
| public static < type of the values processed by this method. T extends Comparable | Returns: a negative value if c1 < c2, zero if c1 = c2 and a positive value if c1 > c2.the first comparable, may be null. c1, final T the second comparable, may be null. c2)Null safe comparison of Comparables. |
| public static < type of the values processed by this method. T extends Comparable | Returns: a negative value if c1 < c2, zero if c1 = c2 and a positive value if c1 > c2.the first comparable, may be null. c1, final T the second comparable, may be null. c2, final boolean if true nullGreater)null is considered greater than a non-null value or if false null is considered less than a
Non-null value.Null safe comparison of Comparables. |
| public static boolean | Returns: the boolean v, unchanged.the boolean value to return. v)Returns the provided value unchanged. |
| public static byte | Returns: the byte v, unchanged.the byte value to return. v)Returns the provided value unchanged. |
| public static char | Returns: the char v, unchanged.the char value to return. v)Returns the provided value unchanged. |
| public static double | Returns: the double v, unchanged.the double value to return. v)Returns the provided value unchanged. |
| public static float | Returns: the float v, unchanged.the float value to return. v)Returns the provided value unchanged. |
| public static int | Returns: the int v, unchanged.the int value to return. v)Returns the provided value unchanged. |
| public static long | Returns: the long v, unchanged.the long value to return. v)Returns the provided value unchanged. |
| public static short | Returns: the short v, unchanged.the short value to return. v)Returns the provided value unchanged. |
| public static < the Object type. T> T | Returns: the genericized Object v, unchanged (typically a String).the genericized Object value to return (typically a String). v)Returns the provided value unchanged. |
| public static byte | Returns: the byte v, unchanged.the byte literal (as an int) value to return. v)Returns the provided value unchanged. |
| public static short | Returns: the byte v, unchanged.the short literal (as an int) value to return. v)Returns the provided value unchanged. |
| public static < the type of the object. T> T | Returns: object if it is not null, defaultValue otherwise.the object, final T Object to test, may be null.the default value to return, may be defaultValue)null.
Deprecated
Use
getIfNull(Object, Object).
Returns a default value if the object passed is |
| public static boolean | Returns: true if the values of both objects are the same.the first object, may be object1, final Object null.the second object, may be object2)null.
Deprecated
this method has been replaced by
java.util.Objects.equals(Object, Object) in Java 7 and will
be removed from future releases.
Compares two objects for equality, where either one or both
objects may be |
| public static < the component type of the array. T> T | Returns: the first value fromvalues which is not null,
or null if there are no non-null values.the values to test, may be values)null or empty.Returns the first value in the array which is not |
| public static < The argument type or null. T> Class | Returns: The argument's Class or null.The argument. object)Delegates to |
| public static < the type of the return values. T> T | Returns: the first return value fromsuppliers which is not null, or null if there are no non-null values.the suppliers returning the values to test. suppliers)null values are ignored. Suppliers may return null or a value of type
T.Executes the given suppliers in order and returns the first return value where a value other than |
| public static < the type of the object. T> T | Returns: object if it is not null, defaultValueSupplier.get() otherwise.the object, final Supplier<T> Object to test, may be null.the default value to return, may be defaultSupplier)null.Returns the given |
| public static < the type of the object. T> T | |
| public static int | Returns: the hash code of the object, or zero if null.the object to obtain the hash code of, may be obj)null.
Deprecated
this method has been replaced by
java.util.Objects.hashCode(Object) in Java 7 and will be removed in future releases.
Gets the hash code of an object returning zero when the object is |
| public static String | Returns: Hash code in hexadecimal format.object for which the hashCode is to be calculated. object)Returns the hexadecimal hash code for the given object per |
| public static int | Returns: the hash code of the objects, or zero if null.the objects to obtain the hash code of, may be objects)null.
Deprecated
this method has been replaced by
java.util.Objects.hash(Object...) in Java 7 and will be removed in future releases.
Gets the hash code for multiple objects. |
| public static String | Returns: Hash code in hexadecimal format.object for which the hashCode is to be calculated. object)Returns the hexadecimal hash code for the given object per |
| public static void | identityToString(final Appendable
the appendable to append to. appendable, final Object the object to create a toString for. object)Appends the toString that would be produced by |
| public static String | Returns: the default toString text, ornull if null passed in.the object to create a toString for, may be object)null.Gets the toString that would be produced by |
| public static void | identityToString(final StrBuilder
the builder to append to. builder, final Object the object to create a toString for. object)
Deprecated
as of 3.6, because StrBuilder was moved to commons-text,
use one of the other
identityToString methods instead.
Appends the toString that would be produced by |
| public static void | identityToString(final StringBuffer
the buffer to append to. buffer, final Object the object to create a toString for. object)Appends the toString that would be produced by |
| public static void | identityToString(final StringBuilder
the builder to append to. builder, final Object the object to create a toString for. object)Appends the toString that would be produced by |
| public static boolean | |
| public static boolean | |
| public static boolean | Returns: true if the object has an unsupported type or is not empty.
and not null, false otherwise.the object)Object to test, may be null.Tests if an Object is not empty and not null. |
| public static < type of the values processed by this method. T extends Comparable | Returns:
the set of comparable values, may be null. values)Null safe comparison of Comparables. |
| public static < type of values processed by this method. T> T | Returns: T at middle position.to use for comparisons. comparator, final T... to compare. items)Finds the "best guess" middle value among comparables. |
| public static < type of values processed by this method. T extends Comparable | Returns: T at middle position.to compare. items)Finds the "best guess" middle value among comparables. |
| public static < type of the values processed by this method T extends Comparable | Returns:
the set of comparable values, may be null values)Null safe comparison of Comparables. |
| public static < type of values processed by this method. T> T | Returns: most populous T,null if non-unique or no items supplied.to check. items)Finds the most frequently occurring item. |
| public static boolean | |
| public static < the type of the reference. T> T | Returns: obj if not null.the object reference to check for nullity. obj)Checks that the specified object reference is not |
| public static < the type of the reference. T> T | Returns: obj if not null.the object reference to check for nullity. obj, final String the exception message. message)Checks that the specified object reference is not |
| public static String | |
| public static String | Returns: the passed in Object's toString, ornullStr if null input.the Object to obj, final String toString, may be null.the String to return if nullStr)null input, may be null.
Deprecated
this method has been replaced by
java.util.Objects.toString(Object, String) in Java 7 and
will be removed in future releases.
Gets the |
| public static String | Returns: the passed in Object's toString, ornullStr if null input.the Object to obj, final Supplier<String> toString, may be null.the Supplier of String used on supplier)null input, may be null.Gets the |
| public static < the obj type (used to provide better source compatibility in 3.14.0). T> String | |
| public static void | wait(final Object
The receiver of the wait call. obj, final Duration How long to wait. duration)Calls |