|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.util.Objects
public final class Objects
Utility methods for manipulating objects.
Method Summary | |
---|---|
static String |
className(Class<?> type)
Return just the name (minus the package) of a class. |
static String |
className(Object object)
Return just the name (minus the package) of an object's class. |
static Object |
cloneBySerialization(Object object)
Clone an object graph by serializing and then deserializing it. |
static Collection |
cloneCollection(Collection collection)
Deep clone a collection by cloning the collection itself and then cloning each entry. |
static Object |
cloneObject(Object object)
Attempts to clone an object instance where generic cloning is required but only an Object reference (with protected clone () access) is held. |
static Method |
findMethod(Class targetClass,
String methodName)
Search the superclass/interface tree of a given class for a method with a given name. |
static Method |
findMethod(Class targetClass,
String methodName,
Class paramClass)
Search for a method taking a parameter compatible with a given parameter class. |
static Method |
findMethod(Class type,
String methodName,
Class[] argTypes)
|
static int |
getIntField(Object obj,
String fieldName)
Shortcut to get the value of an int field from an object using reflection. |
static Method |
getMethod(Class theClass,
String methodName,
Class param)
Get a method using reflection, returning null if not found. |
static Object |
instantiate(Class type)
Instantiate a value of the given class. |
static boolean |
objectsEqual(Object o1,
Object o2)
Test for equality, handling shortcut when o1 == o2 and when one or both of the values are null. |
static boolean |
objectsEqualEx(Object o1,
Object o2)
Extended version of objectsEqual () that does deep equality checking of arrays. |
static Object |
simpleClone(Object object)
Simple way to clone objects via dyanamic invokation of the clone () method. |
static Throwable |
unwrapException(Throwable ex)
Unwrap one of Java's various exceptions that exist to wrap another one (ie hide the real source of the problem). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean objectsEqual(Object o1, Object o2)
objectsEqualEx(Object, Object)
public static boolean objectsEqualEx(Object o1, Object o2)
objectsEqual(Object, Object)
public static Object cloneObject(Object object) throws CloneNotSupportedException
IDataObject
's are cloned using
DataObjects.deepClone(IDataObject)
.
CloneNotSupportedException
- if object is not cloneable
or clone () threw an exception (eg clone () is protected).simpleClone(Object)
public static Object simpleClone(Object object) throws CloneNotSupportedException
CloneNotSupportedException
cloneObject(Object)
public static Collection cloneCollection(Collection collection) throws CloneNotSupportedException
collection
- The collection to clone.
CloneNotSupportedException
public static Object cloneBySerialization(Object object) throws CloneNotSupportedException
object
- The object to clone.
CloneNotSupportedException
- if an error occurs while serializing or
serializing.public static Throwable unwrapException(Throwable ex)
public static int getIntField(Object obj, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException
obj
- The object.fieldName
- The field name. May be private.
SecurityException
- If the security manager bounces us.
NoSuchFieldException
- Guess
IllegalArgumentException
- If the field is not an int.public static Object instantiate(Class type) throws IllegalArgumentException
IllegalArgumentException
public static Method getMethod(Class theClass, String methodName, Class param)
public static Method findMethod(Class targetClass, String methodName, Class paramClass)
public static Method findMethod(Class targetClass, String methodName)
public static Method findMethod(Class type, String methodName, Class[] argTypes)
public static String className(Object object)
public static String className(Class<?> type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |