Class FilteringDependencyVisitor

  • All Implemented Interfaces:
    DependencyVisitor

    public final class FilteringDependencyVisitor
    extends Object
    implements DependencyVisitor
    A dependency visitor that delegates to another visitor if nodes match a filter. Note that in case of a mismatching node, the children of that node are still visisted and presented to the filter.
    • Constructor Detail

      • FilteringDependencyVisitor

        public FilteringDependencyVisitor​(DependencyVisitor visitor,
                                          DependencyFilter filter)
        Creates a new visitor that delegates traversal of nodes matching the given filter to the specified visitor.
        Parameters:
        visitor - The visitor to delegate to, must not be null.
        filter - The filter to apply, may be null to not filter.
    • Method Detail

      • getVisitor

        public DependencyVisitor getVisitor()
        Gets the visitor to which this visitor delegates to.
        Returns:
        The visitor being delegated to, never null.
      • getFilter

        public DependencyFilter getFilter()
        Gets the filter being applied before delegation.
        Returns:
        The filter being applied or null if none.
      • visitEnter

        public boolean visitEnter​(DependencyNode node)
        Description copied from interface: DependencyVisitor
        Notifies the visitor of a node visit before its children have been processed.
        Specified by:
        visitEnter in interface DependencyVisitor
        Parameters:
        node - The dependency node being visited, must not be null.
        Returns:
        true to visit child nodes of the specified node as well, false to skip children.
      • visitLeave

        public boolean visitLeave​(DependencyNode node)
        Description copied from interface: DependencyVisitor
        Notifies the visitor of a node visit after its children have been processed. Note that this method is always invoked regardless whether any children have actually been visited.
        Specified by:
        visitLeave in interface DependencyVisitor
        Parameters:
        node - The dependency node being visited, must not be null.
        Returns:
        true to visit siblings nodes of the specified node as well, false to skip siblings.