Class AnnotationAttributeMatcher

java.lang.Object
tech.picnic.errorprone.bugpatterns.util.AnnotationAttributeMatcher
All Implemented Interfaces:
Serializable

public final class AnnotationAttributeMatcher extends Object implements Serializable
A matcher of (annotation, attribute) pairs.

This class allows one to define a whitelist or blacklist of annotations or their attributes. Annotations are identified by their fully qualified name.

See Also:
  • Method Details

    • create

      public static AnnotationAttributeMatcher create(Optional<? extends List<String>> inclusions, Iterable<String> exclusions)
      Creates an AnnotationAttributeMatcher.

      Each string provided to this method must be of the form "some.fully.qualified.AnnotationType" or "some.fully.qualified.AnnotationType#attribute".

      Parameters:
      inclusions - If specified, only the listed annotations or annotation attributes are matched.
      exclusions - The listed annotations or annotation attributes are not matched.
      Returns:
      A non-null AnnotationAttributeMatcher.
    • extractMatchingArguments

      public Stream<? extends ExpressionTree> extractMatchingArguments(AnnotationTree tree)
      Returns the subset of arguments of the given AnnotationTree matched by this instance.
      Parameters:
      tree - The annotation AST node to be inspected.
      Returns:
      Any matching annotation arguments.