Class ChildMultiMatcher<T extends com.sun.source.tree.Tree,​N extends com.sun.source.tree.Tree>

java.lang.Object
com.google.errorprone.matchers.ChildMultiMatcher<T,​N>
Type Parameters:
T - the type of the node to match on
N - the type of the subnode that the given matcher should match
All Implemented Interfaces:
Matcher<T>, MultiMatcher<T,​N>, Serializable
Direct Known Subclasses:
AnnotationMatcher, ConstructorOfClass, HasArguments, MethodHasParameters

public abstract class ChildMultiMatcher<T extends com.sun.source.tree.Tree,​N extends com.sun.source.tree.Tree>
extends Object
implements MultiMatcher<T,​N>
A MultiMatcher that applies a matcher across multiple children of a single ancestor node. Configurable to return true if any of, all of, or the last node matches. In the any or last of cases, provides access to the node that matched.
Author:
eaftan@google.com (Eddie Aftandilian)
See Also:
Serialized Form
  • Field Details

    • nodeMatcher

      protected final Matcher<N extends com.sun.source.tree.Tree> nodeMatcher
      The matcher to apply to the subnodes in question.
  • Constructor Details

  • Method Details

    • matches

      public boolean matches​(T tree, VisitorState state)
      Specified by:
      matches in interface Matcher<T extends com.sun.source.tree.Tree>
    • multiMatchResult

      public MultiMatcher.MultiMatchResult<N> multiMatchResult​(T tree, VisitorState state)
      Description copied from interface: MultiMatcher
      Attempt to match the given node, and return the associated subnodes that matched.
      Specified by:
      multiMatchResult in interface MultiMatcher<T extends com.sun.source.tree.Tree,​N extends com.sun.source.tree.Tree>
    • getChildNodes

      @ForOverride protected abstract Iterable<? extends N> getChildNodes​(T tree, VisitorState state)
      Returns the set of child nodes to match. The nodes must be immediate children of the current node to ensure the TreePath calculation is correct. MultiMatchers with other requirements should not subclass ChildMultiMatcher.