Package org.glassfish.pfl.test
Class ObjectUtility
- java.lang.Object
-
- org.glassfish.pfl.test.ObjectUtility
-
public final class ObjectUtility extends java.lang.Object
General object related utilities. This class must not depend on generated log wrappers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ObjectUtility.ClassMap
private static interface
ObjectUtility.ObjectPrinter
private static class
ObjectUtility.Pair
-
Field Summary
Fields Modifier and Type Field Description private ObjectUtility.ClassMap
classToPrinter
private ObjectUtility.ObjectPrinter
collectionPrinter
private static ObjectUtility
compact
private int
increment
private int
initialLevel
private boolean
isIndenting
private ObjectUtility.ObjectPrinter
mapPrinter
private ObjectUtility.ObjectPrinter
propertiesPrinter
private static ObjectUtility
standard
private boolean
useToString
-
Constructor Summary
Constructors Modifier Constructor Description private
ObjectUtility(boolean useToString, boolean isIndenting, int initialLevel, int increment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
a()
private static void
b()
private static void
c()
private void
checkPackageAccess(java.lang.Class cls)
static java.lang.String
compactObjectToString(java.lang.Object object)
static java.lang.Object
concatenateArrays(java.lang.Object arr1, java.lang.Object arr2)
If arr1 and arr2 are both arrays of the same component type, return an array of that component type that consists of the elements of arr1 followed by the elements of arr2.private static void
d()
static java.lang.String
defaultObjectToString(java.lang.Object object)
A convenience method that gives the default behavior: use indenting to display the object's structure and do not use built-in toString methods.static void
displayException(java.lang.Throwable thr)
private static void
e()
private static boolean
equalArrays(java.util.Map counterpart, java.util.Set considered, java.lang.Object[] arr1, java.lang.Object[] arr2)
private static boolean
equalLists(java.util.Map counterpart, java.util.Set considered, java.util.List list1, java.util.List list2)
private static boolean
equalMaps(java.util.Map counterpart, java.util.Set considered, java.util.Map map1, java.util.Map map2)
static boolean
equals(java.lang.Object obj1, java.lang.Object obj2)
private static boolean
equalSets(java.util.Map counterpart, java.util.Set considered, java.util.Set set1, java.util.Set set2)
private static boolean
equalsHelper(java.util.Map counterpart, java.util.Set considered, java.lang.Object obj1, java.lang.Object obj2)
private static boolean
equalsObject(java.util.Map counterpart, java.util.Set considered, java.lang.Class cls, java.lang.Object obj1, java.lang.Object obj2)
private static boolean
equalsObjectFields(java.util.Map counterpart, java.util.Set considered, java.lang.Class cls, java.lang.Object obj1, java.lang.Object obj2)
private java.lang.reflect.Field[]
getDeclaredFields(java.lang.Class cls)
private void
handleArray(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
private void
handleObject(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
static void
main(java.lang.String[] args)
static ObjectUtility
make()
Get the standard Utility object that supports objectToString with indented display and no use of toString() methods.static ObjectUtility
make(boolean useToString, boolean isIndenting)
Construct an Utility instance with the desired objectToString behavior.static ObjectUtility
make(boolean useToString, boolean isIndenting, int initialLevel, int increment)
Construct an Utility instance with the desired objectToString behavior.private boolean
mustUseToString(java.lang.Class cls)
java.lang.String
objectToString(java.lang.Object obj)
objectToString handles display of arbitrary objects.private void
objectToStringHelper(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
private static void
sop(java.lang.String msg)
-
-
-
Field Detail
-
useToString
private boolean useToString
-
isIndenting
private boolean isIndenting
-
initialLevel
private int initialLevel
-
increment
private int increment
-
classToPrinter
private ObjectUtility.ClassMap classToPrinter
-
standard
private static ObjectUtility standard
-
compact
private static ObjectUtility compact
-
propertiesPrinter
private ObjectUtility.ObjectPrinter propertiesPrinter
-
collectionPrinter
private ObjectUtility.ObjectPrinter collectionPrinter
-
mapPrinter
private ObjectUtility.ObjectPrinter mapPrinter
-
-
Method Detail
-
make
public static ObjectUtility make(boolean useToString, boolean isIndenting, int initialLevel, int increment)
Construct an Utility instance with the desired objectToString behavior.
-
make
public static ObjectUtility make(boolean useToString, boolean isIndenting)
Construct an Utility instance with the desired objectToString behavior.
-
make
public static ObjectUtility make()
Get the standard Utility object that supports objectToString with indented display and no use of toString() methods.
-
defaultObjectToString
public static java.lang.String defaultObjectToString(java.lang.Object object)
A convenience method that gives the default behavior: use indenting to display the object's structure and do not use built-in toString methods.
-
compactObjectToString
public static java.lang.String compactObjectToString(java.lang.Object object)
-
objectToString
public java.lang.String objectToString(java.lang.Object obj)
objectToString handles display of arbitrary objects. It correctly handles objects whose elements form an arbitrary graph. It uses reflection to display the contents of any kind of object. An object's toString() method may optionally be used, but the default is to ignore all toString() methods except for those defined for primitive types, primitive type wrappers, and strings.
-
equals
public static boolean equals(java.lang.Object obj1, java.lang.Object obj2)
-
concatenateArrays
public static java.lang.Object concatenateArrays(java.lang.Object arr1, java.lang.Object arr2)
If arr1 and arr2 are both arrays of the same component type, return an array of that component type that consists of the elements of arr1 followed by the elements of arr2. Throws IllegalArgumentException otherwise.
-
objectToStringHelper
private void objectToStringHelper(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
-
mustUseToString
private boolean mustUseToString(java.lang.Class cls)
-
checkPackageAccess
private void checkPackageAccess(java.lang.Class cls)
-
getDeclaredFields
private java.lang.reflect.Field[] getDeclaredFields(java.lang.Class cls)
-
handleObject
private void handleObject(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
-
handleArray
private void handleArray(java.util.IdentityHashMap printed, ObjectWriter result, java.lang.Object obj)
-
equalsHelper
private static boolean equalsHelper(java.util.Map counterpart, java.util.Set considered, java.lang.Object obj1, java.lang.Object obj2)
-
equalsObject
private static boolean equalsObject(java.util.Map counterpart, java.util.Set considered, java.lang.Class cls, java.lang.Object obj1, java.lang.Object obj2)
-
equalsObjectFields
private static boolean equalsObjectFields(java.util.Map counterpart, java.util.Set considered, java.lang.Class cls, java.lang.Object obj1, java.lang.Object obj2)
-
equalArrays
private static boolean equalArrays(java.util.Map counterpart, java.util.Set considered, java.lang.Object[] arr1, java.lang.Object[] arr2)
-
equalMaps
private static boolean equalMaps(java.util.Map counterpart, java.util.Set considered, java.util.Map map1, java.util.Map map2)
-
equalSets
private static boolean equalSets(java.util.Map counterpart, java.util.Set considered, java.util.Set set1, java.util.Set set2)
-
equalLists
private static boolean equalLists(java.util.Map counterpart, java.util.Set considered, java.util.List list1, java.util.List list2)
-
sop
private static void sop(java.lang.String msg)
-
displayException
public static void displayException(java.lang.Throwable thr)
-
a
private static void a()
-
b
private static void b()
-
c
private static void c()
-
d
private static void d()
-
e
private static void e()
-
main
public static void main(java.lang.String[] args)
-
-