|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.test.DeepCloneTestUtils
public class DeepCloneTestUtils
This class provides various utility methods used to test deep cloning implementations
Constructor Summary | |
---|---|
DeepCloneTestUtils()
|
Method Summary | ||
---|---|---|
static java.util.IdentityHashMap<java.lang.Object,java.lang.Object> |
buildCloneMap(java.lang.Object orig,
java.lang.Object clone,
java.util.Comparator<java.lang.Object> comparator,
java.lang.String... packagePrefixes)
This method is used to test deep cloning implementations. |
|
static
|
getAllReferencedObjects(java.lang.Object root,
java.lang.Class<T> type,
java.lang.String... packagePrefixes)
This works analogous to getAllReferencedObjects(Object, String...) but allows to limit
the results to a certain type. |
|
static IdentityHashSet<java.lang.Object> |
getAllReferencedObjects(java.lang.Object root,
java.lang.String... packagePrefixes)
Get all objects an object references. |
|
static
|
testDeepCloning(java.lang.Object orig,
java.lang.Object clone,
IIdProvider<I,java.lang.Object> idProvider,
java.lang.String... packagePrefixes)
This method uses buildCloneMap(Object, Object, Comparator, String...) to build a
map between the original object network and clone network. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DeepCloneTestUtils()
Method Detail |
---|
public static java.util.IdentityHashMap<java.lang.Object,java.lang.Object> buildCloneMap(java.lang.Object orig, java.lang.Object clone, java.util.Comparator<java.lang.Object> comparator, java.lang.String... packagePrefixes)
To achieve this, the method uses reflection to determine the methods that
define the object networks, typically examples are
getChildren()
or getParent()
. To limit the
selection of methods, a list of package prefixes may specified. Only
methods that do return a type matched by one of the prefixes are taken
into account. Additionally all methods that return an implementation of
Collection
are considered. However, we currently do not consider
nested collections like Set
.
To establish the mapping between the networks a comparator is needed to order members of object in both networks in the same way. This comparator must not be capable of comparing all possible types but must support ordering possible member type combinations of the object network under investigation. Usually, the object already provide some means of identification via IDs or full qualified names. These can be used to implement the comparator.
orig
- point of entry for the original networkclone
- point of entry for the clone networkcomparator
- the comparator is needed to compare the two networkspackagePrefixes
- list of package prefixes to take into accountpublic static <T> IdentityHashSet<T> getAllReferencedObjects(java.lang.Object root, java.lang.Class<T> type, java.lang.String... packagePrefixes)
getAllReferencedObjects(Object, String...)
but allows to limit
the results to a certain type.
public static IdentityHashSet<java.lang.Object> getAllReferencedObjects(java.lang.Object root, java.lang.String... packagePrefixes)
getChildren()
or
getParent()
. To limit the selection of methods, a list of
package prefixes must be specified. Only methods that do return a type
matched by one of the prefixes are taken into account. Additionally all
methods that return an implementation of Collection
are
considered.
root
- root of the object networkpackagePrefixes
- list of package prefixes to take into accountpublic static <I extends java.lang.Comparable<I>> java.util.IdentityHashMap<java.lang.Object,java.lang.Object> testDeepCloning(java.lang.Object orig, java.lang.Object clone, IIdProvider<I,java.lang.Object> idProvider, java.lang.String... packagePrefixes)
buildCloneMap(Object, Object, Comparator, String...)
to build a
map between the original object network and clone network. Based on this
map it performs the following checks:
orig
- point of entry for the original networkclone
- point of entry for the clone networkidProvider
- an id provider that generates an id for all objects in the
networks. This is necessary to establish comparable orderings.packagePrefixes
- list of package prefixes to take into account
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |