final class ObjectGraphWalker
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static interface |
ObjectGraphWalker.Visitor
The visitor to execute the function on each node of the graph
This is only to be used for the sizing of an object graph in memory!
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ABORT_MESSAGE |
private WeakIdentityConcurrentMap<java.lang.Class<?>,java.lang.Boolean> |
classCache |
private static java.lang.String |
CONTINUE_MESSAGE |
private WeakIdentityConcurrentMap<java.lang.Class<?>,java.lang.ref.SoftReference<java.util.Collection<java.lang.reflect.Field>>> |
fieldCache |
private static org.slf4j.Logger |
LOG |
private SizeOfFilter |
sizeOfFilter |
private static java.lang.String |
TC_INTERNAL_FIELD_PREFIX |
private static boolean |
USE_VERBOSE_DEBUG_LOGGING |
private static java.lang.String |
VERBOSE_DEBUG_LOGGING |
private ObjectGraphWalker.Visitor |
visitor |
Constructor and Description |
---|
ObjectGraphWalker(ObjectGraphWalker.Visitor visitor,
SizeOfFilter filter)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private long |
calculateSize(java.lang.Object ref) |
private boolean |
checkMaxDepth(int maxDepth,
boolean abortWhenMaxDepthExceeded,
boolean warned,
java.util.IdentityHashMap<java.lang.Object,java.lang.Object> visited) |
private static java.util.Collection<java.lang.reflect.Field> |
getAllFields(java.lang.Class<?> refClass)
Returns all non-primitive fields for the entire class hierarchy of a type
|
private java.util.Collection<java.lang.reflect.Field> |
getFilteredFields(java.lang.Class<?> refClass)
Returns the filtered fields for a particular type
|
private static boolean |
getVerboseSizeOfDebugLogging() |
private static boolean |
isSharedFlyweight(java.lang.Object obj) |
private static void |
nullSafeAdd(java.util.Stack<java.lang.Object> toVisit,
java.lang.Object o) |
private boolean |
shouldWalkClass(java.lang.Class<?> refClass) |
(package private) long |
walk(int maxDepth,
boolean abortWhenMaxDepthExceeded,
java.lang.Object... root)
Walk the graph and call into the "visitor"
|
private static final org.slf4j.Logger LOG
private static final java.lang.String TC_INTERNAL_FIELD_PREFIX
private static final java.lang.String VERBOSE_DEBUG_LOGGING
private static final java.lang.String CONTINUE_MESSAGE
private static final java.lang.String ABORT_MESSAGE
private static final boolean USE_VERBOSE_DEBUG_LOGGING
private final WeakIdentityConcurrentMap<java.lang.Class<?>,java.lang.ref.SoftReference<java.util.Collection<java.lang.reflect.Field>>> fieldCache
private final WeakIdentityConcurrentMap<java.lang.Class<?>,java.lang.Boolean> classCache
private final SizeOfFilter sizeOfFilter
private final ObjectGraphWalker.Visitor visitor
ObjectGraphWalker(ObjectGraphWalker.Visitor visitor, SizeOfFilter filter)
visitor
- the visitor to usefilter
- the filteringObjectGraphWalker.Visitor
,
SizeOfFilter
private static boolean getVerboseSizeOfDebugLogging()
long walk(int maxDepth, boolean abortWhenMaxDepthExceeded, java.lang.Object... root)
maxDepth
- maximum depth to traverse the object graphabortWhenMaxDepthExceeded
- true if the object traversal should be aborted when the max depth is exceededroot
- the roots of the objects (a shared graph will only be visited once)private long calculateSize(java.lang.Object ref)
private boolean checkMaxDepth(int maxDepth, boolean abortWhenMaxDepthExceeded, boolean warned, java.util.IdentityHashMap<java.lang.Object,java.lang.Object> visited)
private java.util.Collection<java.lang.reflect.Field> getFilteredFields(java.lang.Class<?> refClass)
refClass
- the typeprivate boolean shouldWalkClass(java.lang.Class<?> refClass)
private static void nullSafeAdd(java.util.Stack<java.lang.Object> toVisit, java.lang.Object o)
private static java.util.Collection<java.lang.reflect.Field> getAllFields(java.lang.Class<?> refClass)
refClass
- the typeprivate static boolean isSharedFlyweight(java.lang.Object obj)