Package org.apache.bval.util
Class ObjectUtils
- java.lang.Object
-
- org.apache.bval.util.ObjectUtils
-
public final class ObjectUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static Annotation[]EMPTY_ANNOTATION_ARRAYstatic Class<?>[]EMPTY_CLASS_ARRAYstatic String[]EMPTY_STRING_ARRAY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]arrayAdd(T[] array, T objectToAdd)static booleanarrayContains(Object[] array, Object objectToFind)Checks if the object is in the given array.static <T> TdefaultIfNull(T object, T defaultValue)Returns a default value if the object passed isnull.static inthashCode(Object o)Get hashcode ofo, taking into account array values.static intindexOf(Object[] array, Object objectToFind)static booleanisEmptyArray(Object array)
-
-
-
Field Detail
-
EMPTY_CLASS_ARRAY
public static final Class<?>[] EMPTY_CLASS_ARRAY
-
EMPTY_STRING_ARRAY
public static final String[] EMPTY_STRING_ARRAY
-
EMPTY_ANNOTATION_ARRAY
public static final Annotation[] EMPTY_ANNOTATION_ARRAY
-
-
Method Detail
-
defaultIfNull
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- Type Parameters:
T- the type of the object- Parameters:
object- theObjectto test, may benulldefaultValue- the default value to return, may benull- Returns:
objectif it is notnull, defaultValue otherwise
-
isEmptyArray
public static boolean isEmptyArray(Object array)
-
arrayContains
public static boolean arrayContains(Object[] array, Object objectToFind)
Checks if the object is in the given array.
The method returns
falseif anullarray is passed in.- Parameters:
array- the array to search throughobjectToFind- the object to find- Returns:
trueif the array contains the object
-
arrayAdd
public static <T> T[] arrayAdd(T[] array, T objectToAdd)
-
hashCode
public static int hashCode(Object o)
Get hashcode ofo, taking into account array values.- Parameters:
o-- Returns:
int- See Also:
Arrays,Objects.hashCode(Object)
-
-