com.threerings.util
Class DeepUtil

java.lang.Object
  extended by com.threerings.util.DeepUtil

public class DeepUtil
extends Object

Various methods that use reflection to perform "deep" operations: copying, comparison, etc. The usual warnings about circular references apply.


Constructor Summary
DeepUtil()
           
 
Method Summary
static
<T> T
copy(T source)
          Creates and returns a deep copy of an object using reflection.
static
<T> T
copy(T source, T dest)
          Creates a deep copy of an object using reflection, storing the result in the object provided if possible.
static
<T> T
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
<T> boolean
equals(T o1, T o2)
          Compares two objects for deep equality.
static int hashCode(Object object)
          Computes the deep hash code of an object.
static
<T> T
transfer(T source, T dest)
          Transfers the state in the shared ancestry of the two arguments from the source to the destination.
static
<T> T
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeepUtil

public DeepUtil()
Method Detail

copy

public static <T> T copy(T source)
Creates and returns a deep copy of an object using reflection.


copy

public static <T> T copy(T source,
                         T dest)
Creates a deep copy of an object using reflection, storing the result in the object provided if possible.

Returns:
the copied object.

copy

public static <T> T 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.

Parameters:
outer - the outer object reference to use for inner object creation, if any.
Returns:
the copied object.

transfer

public static <T> T transfer(T source,
                             T dest)
Transfers the state in the shared ancestry of the two arguments from the source to the destination. If the two objects are instances of the same class, then this is equivalent to copy(T).

Returns:
a reference to the destination object.

transfer

public static <T> T transfer(T source,
                             T dest,
                             Object outer)
Transfers the state in the shared ancestry of the two arguments from the source to the destination. If the two objects are instances of the same class, then this is equivalent to copy(T).

Parameters:
outer - the outer object reference to use for inner object creation, if any.
Returns:
a reference to the destination object.

equals

public static <T> boolean equals(T o1,
                                 T o2)
Compares two objects for deep equality.


hashCode

public static int hashCode(Object object)
Computes the deep hash code of an object.



Copyright © 2011. All Rights Reserved.