Class ObjectGraphWalker


  • final class ObjectGraphWalker
    extends java.lang.Object
    This will walk an object graph and let you execute some "function" along the way
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • VERBOSE_DEBUG_LOGGING

        private static final java.lang.String VERBOSE_DEBUG_LOGGING
        See Also:
        Constant Field Values
      • USE_VERBOSE_DEBUG_LOGGING

        private static final boolean USE_VERBOSE_DEBUG_LOGGING
      • fieldCache

        private final WeakIdentityConcurrentMap<java.lang.Class<?>,​java.lang.ref.SoftReference<java.util.Collection<java.lang.reflect.Field>>> fieldCache
      • bypassFlyweight

        private final boolean bypassFlyweight
    • Method Detail

      • getVerboseSizeOfDebugLogging

        private static boolean getVerboseSizeOfDebugLogging()
      • walk

        long walk​(java.lang.Object... root)
        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

        long walk​(VisitorListener visitorListener,
                  java.lang.Object... root)
        Walk the graph and call into the "visitor"
        Parameters:
        visitorListener - A decorator for the Visitor
        root - the roots of the objects (a shared graph will only be visited once)
        Returns:
        the sum of all Visitor#visit returned values
      • getFilteredFields

        private java.util.Collection<java.lang.reflect.Field> getFilteredFields​(java.lang.Class<?> refClass)
        Returns the filtered fields for a particular type
        Parameters:
        refClass - the type
        Returns:
        A collection of fields to be visited
      • shouldWalkClass

        private boolean shouldWalkClass​(java.lang.Class<?> refClass)
      • nullSafeAdd

        private static void nullSafeAdd​(java.util.Deque<java.lang.Object> toVisit,
                                        java.lang.Object o)
      • getAllFields

        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
        Parameters:
        refClass - the type
        Returns:
        all fields for that type
      • byPassIfFlyweight

        private boolean byPassIfFlyweight​(java.lang.Object obj)