public class UtlObjectGraph extends Object
This class IS NOT intended to be used by end users.
Modifier and Type | Class and Description |
---|---|
static class |
UtlObjectGraph.BasePopulationHelper
A helper base class to assist in object population.
|
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 and Description |
---|
UtlObjectGraph() |
Modifier and Type | Method and Description |
---|---|
static <T> Object |
createRandomArray(Class<T> clazz,
int maxLength,
Random random) |
static String |
createRandomString(int length,
Random random)
Creates a random string of the given length.
|
static <T> boolean |
deepApiEquals(T o1,
T o2,
StringBuffer diffSummary,
Collection<Class<?>> consideredClasses)
|
static <T> boolean |
deepApiEquals(T o1,
T o2,
StringBuffer diffSummary,
Collection<Class<?>> consideredClasses,
UtlObjectGraph.ComparatorFactory comparatorFactory)
Tests if two objects are equal from an api perspective.
|
static <T> boolean |
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 <T> boolean |
deepEquals(T o1,
T o2) |
static <T> String |
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) |
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 providedpublic 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 providedpublic 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 providedpublic 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.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 comparepublic static <T> boolean deepApiEquals(T o1, T o2, StringBuffer diffSummary, Collection<Class<?>> consideredClasses) throws Exception
o1
- The first objecto2
- The second objectdiffSummary
- The summary for diffs or null for no summaryconsideredClasses
- The apis to consider in comparisonException
- 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 comparisonException
- 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 comparisonException
- If there is an error checking equality.public static <T> boolean deepEquals(T o1, T o2)
public static String createRandomString(int length, Random random)
length
- The max length of the string to create.random
- The seedpublic static final void visitBeanFields(Class<?> type, UtlObjectGraph.FieldAccessorVisitor visitor)
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.