public final class ObjectUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static Annotation[] |
EMPTY_ANNOTATION_ARRAY |
static Class<?>[] |
EMPTY_CLASS_ARRAY |
static String[] |
EMPTY_STRING_ARRAY |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
arrayAdd(T[] array,
T objectToAdd) |
static boolean |
arrayContains(Object[] array,
Object objectToFind)
Checks if the object is in the given array.
|
static <T> T |
defaultIfNull(T object,
T defaultValue)
Returns a default value if the object passed is
null. |
static int |
hashCode(Object o)
Get hashcode of
o, taking into account array values. |
static int |
indexOf(Object[] array,
Object objectToFind) |
static boolean |
isEmptyArray(Object array) |
public static final Class<?>[] EMPTY_CLASS_ARRAY
public static final String[] EMPTY_STRING_ARRAY
public static final Annotation[] EMPTY_ANNOTATION_ARRAY
public static <T> T defaultIfNull(T object,
T defaultValue)
Returns a default value if the object passed is null.
ObjectUtils.defaultIfNull(null, null) = null
ObjectUtils.defaultIfNull(null, "") = ""
ObjectUtils.defaultIfNull(null, "zz") = "zz"
ObjectUtils.defaultIfNull("abc", *) = "abc"
ObjectUtils.defaultIfNull(Boolean.TRUE, *) = Boolean.TRUE
T - the type of the objectobject - the Object to test, may be nulldefaultValue - the default value to return, may be nullobject if it is not null, defaultValue otherwisepublic static boolean isEmptyArray(Object array)
public static boolean arrayContains(Object[] array, Object objectToFind)
Checks if the object is in the given array.
The method returns false if a null array is passed in.
array - the array to search throughobjectToFind - the object to findtrue if the array contains the objectpublic static <T> T[] arrayAdd(T[] array,
T objectToAdd)
public static int hashCode(Object o)
o, taking into account array values.o - intArrays,
Objects.hashCode(Object)Copyright © 2010–2020 The Apache Software Foundation. All rights reserved.