Interface Annotatable

All Superinterfaces:
net.sourceforge.pmd.lang.ast.impl.GenericNode<JavaNode>, JavaNode, net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode<JavaNode>, net.sourceforge.pmd.lang.ast.Node, net.sourceforge.pmd.reporting.Reportable, net.sourceforge.pmd.lang.ast.TextAvailableNode
All Known Subinterfaces:
ASTExecutableDeclaration, ASTReferenceType, ASTType, ASTTypeDeclaration, ModifierOwner
All Known Implementing Classes:
ASTAmbiguousName, ASTAnnotationTypeDeclaration, ASTAnonymousClassDeclaration, ASTArrayDimExpr, ASTArrayType, ASTArrayTypeDim, ASTCatchParameter, ASTClassDeclaration, ASTClassType, ASTCompactConstructorDeclaration, ASTConstructorDeclaration, ASTEnumConstant, ASTEnumDeclaration, ASTFieldDeclaration, ASTFormalParameter, ASTImplicitClassDeclaration, ASTIntersectionType, ASTLambdaParameter, ASTLocalVariableDeclaration, ASTMethodDeclaration, ASTModuleDeclaration, ASTPackageDeclaration, ASTPrimitiveType, ASTRecordComponent, ASTRecordDeclaration, ASTTypeParameter, ASTTypePattern, ASTUnionType, ASTVariableId, ASTVoidType, ASTWildcardType

public interface Annotatable extends JavaNode
Marks nodes that can be annotated. Annotations are most often the first few children of the node they apply to. E.g. in @Positive int, the @Positive annotation is a child of the PrimitiveType node. This contrasts with PMD 6.0 grammar, where the annotations were most often the preceding siblings.
  • Field Summary

    Fields inherited from interface net.sourceforge.pmd.lang.ast.Node

    COORDS_COMPARATOR
  • Method Summary

    Modifier and Type
    Method
    Description
    getAnnotation(String binaryName)
    Returns a specific annotation on this node, or null if absent.
    default net.sourceforge.pmd.lang.ast.NodeStream<ASTAnnotation>
    Returns all annotations present on this node.
    default boolean
    Returns true if an annotation with the given type is applied to this node.
    default boolean
    isAnnotationPresent(String annotQualifiedName)
    Returns true if an annotation with the given qualified name is applied to this node.
    default boolean
    Checks whether any annotation is present on this node.

    Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode

    ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getParent, getPreviousSibling

    Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode

    getEnclosingType, getRoot, getSymbolTable, getTypeSystem

    Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode

    getFirstToken, getLastToken, tokens

    Methods inherited from interface net.sourceforge.pmd.lang.ast.Node

    acceptVisitor, ancestors, children, compareLocation, descendants, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getReportLocation, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasImageEqualTo, isFindBoundary

    Methods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode

    getOriginalText, getText, getTextRegion
  • Method Details

    • getDeclaredAnnotations

      default net.sourceforge.pmd.lang.ast.NodeStream<ASTAnnotation> getDeclaredAnnotations()
      Returns all annotations present on this node.
    • isAnnotationPresent

      default boolean isAnnotationPresent(String annotQualifiedName)
      Returns true if an annotation with the given qualified name is applied to this node.
      Parameters:
      annotQualifiedName - Note: for now, canonical names are tolerated, this may be changed in PMD 7.
    • isAnnotationPresent

      default boolean isAnnotationPresent(Class<?> type)
      Returns true if an annotation with the given type is applied to this node.
    • getAnnotation

      default ASTAnnotation getAnnotation(String binaryName)
      Returns a specific annotation on this node, or null if absent.
      Parameters:
      binaryName - Binary name of the annotation type. Note: for now, canonical names are tolerated, this may be changed in PMD 7.
    • isAnyAnnotationPresent

      default boolean isAnyAnnotationPresent(Collection<String> binaryNames)
      Checks whether any annotation is present on this node.
      Parameters:
      binaryNames - Collection that contains binary names of annotations. Note: for now, canonical names are tolerated, this may be changed in PMD 7.
      Returns:
      true if any annotation is present on this node, else false