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 boolean |
isEmpty(Object[] array) |
static <T> boolean |
isNotEmpty(T[] 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 <T> boolean isNotEmpty(T[] array)
public static boolean isEmpty(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)
Copyright © 2010–2025 The Apache Software Foundation. All rights reserved.