public final class Objects
extends java.lang.Object
Object utilities.| Constructor and Description |
|---|
Objects() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
copy(java.io.Serializable obj)
Copy an serializable object deeply.
|
static java.lang.Object |
deref(java.lang.Object obj)
Dereference the given object if it is non-null and is an
instance of
Reference. |
static <T> T |
deref(java.lang.Object obj,
java.lang.Class<T> expected)
Dereference an object
|
static boolean |
equals(java.lang.Object[] a,
java.lang.Object[] b)
Test the equality of two object arrays.
|
static boolean |
equals(java.lang.Object[] a,
java.lang.Object[] b,
boolean deep)
Test the equality of two object arrays.
|
static boolean |
equals(java.lang.Object first,
java.lang.Object second)
Test the equality of two objects.
|
static java.lang.reflect.Constructor |
getCompatibleConstructor(java.lang.Class type,
java.lang.Class valueType)
Get a compatible constructor for the given value type
|
static boolean |
isArray(java.lang.Object obj)
Check if the given object is an array (primitve or native).
|
static java.lang.Object[] |
toArray(java.lang.Object obj) |
public static java.lang.reflect.Constructor getCompatibleConstructor(java.lang.Class type,
java.lang.Class valueType)
type - Class to look for constructor invalueType - Argument type for constructorpublic static java.lang.Object copy(java.io.Serializable obj)
throws java.io.IOException,
java.lang.ClassNotFoundException
obj - Object to copy.java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic static java.lang.Object deref(java.lang.Object obj)
Reference. If the object is null
then null is returned. If the object is not an instance of
Reference, then the object is returned.obj - Object to dereference.public static <T> T deref(java.lang.Object obj,
java.lang.Class<T> expected)
T - the expected typeobj - the object or referenceexpected - the expected typepublic static boolean isArray(java.lang.Object obj)
obj - Object to test.public static java.lang.Object[] toArray(java.lang.Object obj)
obj - Object to convert to an array. Converts primitive
arrays to Object arrays consisting of their wrapper
classes. If the object is not an array (object or primitve)
then a new array of the given type is created and the
object is set as the sole element.public static boolean equals(java.lang.Object[] a,
java.lang.Object[] b,
boolean deep)
a - The first array.b - The second array.deep - True to traverse elements which are arrays.public static boolean equals(java.lang.Object[] a,
java.lang.Object[] b)
a - The first array.b - The second array.public static boolean equals(java.lang.Object first,
java.lang.Object second)
first - the first obejctsecond - the second object