Package org.ehcache.sizeof
Class ObjectGraphWalker
java.lang.Object
org.ehcache.sizeof.ObjectGraphWalker
This will walk an object graph and let you execute some "function" along the way
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
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! -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final WeakIdentityConcurrentMap
<Class<?>, Boolean> private final WeakIdentityConcurrentMap
<Class<?>, SoftReference<Collection<Field>>> private static final org.slf4j.Logger
private final SizeOfFilter
private static final boolean
private static final String
private final ObjectGraphWalker.Visitor
-
Constructor Summary
ConstructorsConstructorDescriptionObjectGraphWalker
(ObjectGraphWalker.Visitor visitor, SizeOfFilter filter, boolean bypassFlyweight) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
byPassIfFlyweight
(Object obj) private static Collection
<Field> getAllFields
(Class<?> refClass) Returns all non-primitive fields for the entire class hierarchy of a typeprivate Collection
<Field> getFilteredFields
(Class<?> refClass) Returns the filtered fields for a particular typeprivate static boolean
private static void
nullSafeAdd
(Deque<Object> toVisit, Object o) private boolean
shouldWalkClass
(Class<?> refClass) (package private) long
Walk the graph and call into the "visitor"(package private) long
walk
(VisitorListener visitorListener, Object... root) Walk the graph and call into the "visitor"
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
VERBOSE_DEBUG_LOGGING
- See Also:
-
USE_VERBOSE_DEBUG_LOGGING
private static final boolean USE_VERBOSE_DEBUG_LOGGING -
fieldCache
-
classCache
-
bypassFlyweight
private final boolean bypassFlyweight -
sizeOfFilter
-
visitor
-
-
Constructor Details
-
ObjectGraphWalker
ObjectGraphWalker(ObjectGraphWalker.Visitor visitor, SizeOfFilter filter, boolean bypassFlyweight) Constructor- Parameters:
visitor
- the visitor to usefilter
- the filteringbypassFlyweight
- the filtering- See Also:
-
-
Method Details
-
getVerboseSizeOfDebugLogging
private static boolean getVerboseSizeOfDebugLogging() -
walk
Walk the graph and call into the "visitor"- Parameters:
root
- the roots of the objects (a shared graph will only be visited once)- Returns:
- the sum of all Visitor#visit returned values
-
walk
Walk the graph and call into the "visitor"- Parameters:
visitorListener
- A decorator for the Visitorroot
- the roots of the objects (a shared graph will only be visited once)- Returns:
- the sum of all Visitor#visit returned values
-
getFilteredFields
Returns the filtered fields for a particular type- Parameters:
refClass
- the type- Returns:
- A collection of fields to be visited
-
shouldWalkClass
-
nullSafeAdd
-
getAllFields
Returns all non-primitive fields for the entire class hierarchy of a type- Parameters:
refClass
- the type- Returns:
- all fields for that type
-
byPassIfFlyweight
-