|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.util.DeepUtil
public class DeepUtil
Various methods that use reflection to perform "deep" operations: copying, comparison, etc. The usual warnings about circular references apply.
| Nested Class Summary | |
|---|---|
protected static class |
DeepUtil.FieldHandler
Copies or compares a field of a single type. |
protected static class |
DeepUtil.ObjectHandler<T>
Performs the actual object operations. |
protected static class |
DeepUtil.ReflectiveObjectHandler
Handles an object according to its reflected fields. |
| Field Summary | |
|---|---|
protected static Map<Class<?>,DeepUtil.ObjectHandler> |
_objectHandlers
Object handlers mapped by class. |
protected static DeepUtil.ObjectHandler |
ARRAY_OBJECT_HANDLER
Field handler for object arrays. |
protected static DeepUtil.FieldHandler |
DEEP_OBJECT_FIELD_HANDLER
Field handler for deep object fields. |
protected static DeepUtil.FieldHandler |
DEFAULT_OBJECT_FIELD_HANDLER
Default handler for object fields. |
protected static DeepUtil.ObjectHandler |
IMMUTABLE_OBJECT_HANDLER
Field handler for immutable fields, which can be handled by reference. |
protected static Map<Class<?>,DeepUtil.FieldHandler> |
PRIMITIVE_FIELD_HANDLERS
Handlers for primitive fields mapped by class. |
protected static DeepUtil.FieldHandler |
SHALLOW_OBJECT_FIELD_HANDLER
Field handler for shallow object fields. |
| Constructor Summary | |
|---|---|
DeepUtil()
|
|
| Method Summary | ||
|---|---|---|
static
|
copy(T source)
Creates and returns a deep copy of an object using reflection. |
|
static
|
copy(T source,
T dest)
Creates a deep copy of an object using reflection, storing the result in the object provided if possible. |
|
static
|
copy(T source,
T dest,
Object outer)
Creates a deep copy of an object using reflection, storing the result in the object provided if possible. |
|
static
|
equals(T o1,
T o2)
Compares two objects for deep equality. |
|
protected static void |
getInstanceFields(Class<?> clazz,
ArrayList<Field> fields)
Populates the supplied list with the copyable/comparable fields of the given class. |
|
protected static DeepUtil.ObjectHandler |
getObjectHandler(Class<?> clazz)
Retrieves the handler for the supplied class. |
|
static int |
hashCode(Object object)
Computes the deep hash code of an object. |
|
static
|
transfer(T source,
T dest)
Transfers the state in the shared ancestry of the two arguments from the source to the destination. |
|
static
|
transfer(T source,
T dest,
Object outer)
Transfers the state in the shared ancestry of the two arguments from the source to the destination. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final DeepUtil.ObjectHandler IMMUTABLE_OBJECT_HANDLER
protected static final Map<Class<?>,DeepUtil.ObjectHandler> _objectHandlers
protected static final DeepUtil.ObjectHandler ARRAY_OBJECT_HANDLER
protected static final Map<Class<?>,DeepUtil.FieldHandler> PRIMITIVE_FIELD_HANDLERS
protected static DeepUtil.FieldHandler DEFAULT_OBJECT_FIELD_HANDLER
protected static DeepUtil.FieldHandler DEEP_OBJECT_FIELD_HANDLER
protected static DeepUtil.FieldHandler SHALLOW_OBJECT_FIELD_HANDLER
| Constructor Detail |
|---|
public DeepUtil()
| Method Detail |
|---|
public static <T> T copy(T source)
public static <T> T copy(T source,
T dest)
public static <T> T copy(T source,
T dest,
Object outer)
outer - the outer object reference to use for inner object creation, if any.
public static <T> T transfer(T source,
T dest)
copy(T).
public static <T> T transfer(T source,
T dest,
Object outer)
copy(T).
outer - the outer object reference to use for inner object creation, if any.
public static <T> boolean equals(T o1,
T o2)
public static int hashCode(Object object)
protected static DeepUtil.ObjectHandler getObjectHandler(Class<?> clazz)
protected static void getInstanceFields(Class<?> clazz,
ArrayList<Field> fields)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||