|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.util.UtlObjectGraph
public class UtlObjectGraph
Convenience class for working with object graphs.
This class IS NOT intended to be used by end users.
Nested Class Summary | |
---|---|
static class |
UtlObjectGraph.BuiltInHandler
The default handler for object population. |
static interface |
UtlObjectGraph.ComparatorFactory
Used to return a custom comparator for a type rather than the default comparator |
static interface |
UtlObjectGraph.FieldAccessorVisitor
Visitor for field introspection. |
static interface |
UtlObjectGraph.PopulationHelper
A helper interface to assist in object population. |
Constructor Summary | |
---|---|
UtlObjectGraph()
|
Method Summary | ||
---|---|---|
static
|
createRandomArray(Class<T> clazz,
int maxLength,
Random random)
|
|
static String |
createRandomString(int length,
Random random)
Creates a random string of the given length. |
|
static
|
deepApiEquals(T o1,
T o2,
StringBuffer diffSummary,
Collection<Class<?>> consideredClasses)
Same as deepApiEquals(o1, o1, buffer, consideredClasses, null) . |
|
static
|
deepApiEquals(T o1,
T o2,
StringBuffer diffSummary,
Collection<Class<?>> consideredClasses,
UtlObjectGraph.ComparatorFactory comparatorFactory)
Tests if two objects are equal from an api perspective. |
|
static
|
deepApiEquals(T o1,
T o2,
StringBuffer diffSummary,
UtlTableFormatter.Format format,
Collection<Class<?>> consideredClasses,
UtlObjectGraph.ComparatorFactory comparatorFactory)
Tests if two objects are equal from an api perspective. |
|
static
|
deepEquals(T o1,
T o2)
|
|
static
|
diffObjects(T o1,
T o2)
Does a deep introspective comparison of the two objects fields returning a summary of how they differ. |
|
static boolean |
equals(Object o1,
Object o2)
|
|
static String |
getLastGetter(Stack<String> stack)
|
|
static boolean |
isVerbose()
|
|
static void |
populateObject(Object o)
Populates an object graph with Random data. |
|
static void |
populateObject(Object o,
Class<?>... consideredClasses)
Populates an object graph with Random data. |
|
static void |
populateObject(Object o,
Collection<Class<?>> consideredClasses)
Populates an object graph with Random data. |
|
static void |
populateObject(Object o,
Collection<Class<?>> consideredClasses,
UtlObjectGraph.PopulationHelper helper)
Populates an object graph with Random data. |
|
static void |
populateObject(Object o,
long seed,
Collection<Class<?>> consideredClasses,
UtlObjectGraph.PopulationHelper helper)
Randomly populates an object with values. |
|
static void |
setVerbose(boolean verbose)
|
|
static String |
unwindStack(Stack<String> stack)
|
|
static void |
visitBeanFields(Class<?> type,
UtlObjectGraph.FieldAccessorVisitor visitor)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UtlObjectGraph()
Method Detail |
---|
public static boolean isVerbose()
public static void setVerbose(boolean verbose)
public static final void populateObject(Object o) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
called
with System.currentTimeMillis()
as the seed, all classes considered and no helper class provided
IllegalArgumentException
IllegalAccessException
InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
public static final void populateObject(Object o, Class<?>... consideredClasses) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
called
with System.currentTimeMillis()
as the seed, and no helper class provided
IllegalArgumentException
IllegalAccessException
InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
public static final void populateObject(Object o, Collection<Class<?>> consideredClasses) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
called
with System.currentTimeMillis()
as the seed, and no helper class provided
IllegalArgumentException
IllegalAccessException
InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
public static final void populateObject(Object o, Collection<Class<?>> consideredClasses, UtlObjectGraph.PopulationHelper helper) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
called
with System.currentTimeMillis()
as the seed.
IllegalArgumentException
IllegalAccessException
InvocationTargetException
populateObject(Object, long, Collection, PopulationHelper)
public static final void populateObject(Object o, long seed, Collection<Class<?>> consideredClasses, UtlObjectGraph.PopulationHelper helper) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
o
- The object to populatesseed
- The seed value to use with the random generator. Useful for populating two object graphs with the same dataconsideredClasses
- The collection of interfaces and classes whose setter/getter methods will be introspected.
InvocationTargetException
- If there is an error reflectively setting a field.
IllegalAccessException
- If a setter cannot be accessed.
IllegalArgumentException
- If an invalid argument is passed to a setter.public static final <T> Object createRandomArray(Class<T> clazz, int maxLength, Random random)
public static <T> String diffObjects(T o1, T o2)
T
- The type of object to compare.o1
- First object to compareo2
- Second object to compare
public static <T> boolean deepApiEquals(T o1, T o2, StringBuffer diffSummary, Collection<Class<?>> consideredClasses) throws Exception
deepApiEquals(o1, o1, buffer, consideredClasses, null)
.
o1
- The first objecto2
- The second objectdiffSummary
- The summary for diffs or null for no summaryconsideredClasses
- The apis to consider in comparison
Exception
- If there is an error checking equality.public static <T> boolean deepApiEquals(T o1, T o2, StringBuffer diffSummary, Collection<Class<?>> consideredClasses, UtlObjectGraph.ComparatorFactory comparatorFactory) throws Exception
o1
- The first objecto2
- The second objectdiffSummary
- If provided a summary of the differences will be generated.consideredClasses
- The apis to consider in comparison
Exception
- If there is an error checking equality.public static <T> boolean deepApiEquals(T o1, T o2, StringBuffer diffSummary, UtlTableFormatter.Format format, Collection<Class<?>> consideredClasses, UtlObjectGraph.ComparatorFactory comparatorFactory) throws Exception
o1
- The first objecto2
- The second objectdiffSummary
- If provided a summary of the differences will be generated.format
- if a diffSummary is specified the format to dump the summary in.consideredClasses
- The apis to consider in comparison
Exception
- If there is an error checking equality.public static String unwindStack(Stack<String> stack)
public static <T> boolean deepEquals(T o1, T o2)
public static boolean equals(Object o1, Object o2)
public static String getLastGetter(Stack<String> stack)
public static String createRandomString(int length, Random random)
length
- The max length of the string to create.random
- The seed
public static final void visitBeanFields(Class<?> type, UtlObjectGraph.FieldAccessorVisitor visitor)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |