Package org.jboss.util
Class Objects
- java.lang.Object
-
- org.jboss.util.Objects
-
public final class Objects extends java.lang.ObjectA collection ofObjectutilities.
-
-
Constructor Summary
Constructors Constructor Description Objects()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Objectcopy(java.io.Serializable obj)Copy an serializable object deeply.static java.lang.Objectderef(java.lang.Object obj)Dereference the given object if it is non-null and is an instance ofReference.static <T> Tderef(java.lang.Object obj, java.lang.Class<T> expected)Dereference an objectstatic booleanequals(java.lang.Object[] a, java.lang.Object[] b)Test the equality of two object arrays.static booleanequals(java.lang.Object[] a, java.lang.Object[] b, boolean deep)Test the equality of two object arrays.static booleanequals(java.lang.Object first, java.lang.Object second)Test the equality of two objects.static java.lang.reflect.ConstructorgetCompatibleConstructor(java.lang.Class type, java.lang.Class valueType)Get a compatible constructor for the given value typestatic booleanisArray(java.lang.Object obj)Check if the given object is an array (primitve or native).static java.lang.Object[]toArray(java.lang.Object obj)
-
-
-
Method Detail
-
getCompatibleConstructor
public static java.lang.reflect.Constructor getCompatibleConstructor(java.lang.Class type, java.lang.Class valueType)Get a compatible constructor for the given value type- Parameters:
type- Class to look for constructor invalueType- Argument type for constructor- Returns:
- Constructor or null
-
copy
public static java.lang.Object copy(java.io.Serializable obj) throws java.io.IOException, java.lang.ClassNotFoundExceptionCopy an serializable object deeply.- Parameters:
obj- Object to copy.- Returns:
- Copied object.
- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
deref
public static java.lang.Object deref(java.lang.Object obj)
Dereference the given object if it is non-null and is an instance ofReference. If the object is null then null is returned. If the object is not an instance ofReference, then the object is returned.- Parameters:
obj- Object to dereference.- Returns:
- Dereferenced object.
-
deref
public static <T> T deref(java.lang.Object obj, java.lang.Class<T> expected)Dereference an object- Type Parameters:
T- the expected type- Parameters:
obj- the object or referenceexpected- the expected type- Returns:
- the object or null
-
isArray
public static boolean isArray(java.lang.Object obj)
Check if the given object is an array (primitve or native).- Parameters:
obj- Object to test.- Returns:
- True of the object is an array.
-
toArray
public static java.lang.Object[] toArray(java.lang.Object obj)
- Parameters:
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.- Returns:
- an Object array for the given object.
-
equals
public static boolean equals(java.lang.Object[] a, java.lang.Object[] b, boolean deep)Test the equality of two object arrays.- Parameters:
a- The first array.b- The second array.deep- True to traverse elements which are arrays.- Returns:
- True if arrays are equal.
-
equals
public static boolean equals(java.lang.Object[] a, java.lang.Object[] b)Test the equality of two object arrays.- Parameters:
a- The first array.b- The second array.- Returns:
- True if arrays are equal.
-
equals
public static boolean equals(java.lang.Object first, java.lang.Object second)Test the equality of two objects. They can be an (multi dimensional) array.- Parameters:
first- the first obejctsecond- the second object- Returns:
- true if equal, false otherwise
-
-