public final class AnnotationUtility extends Object
Modifier and Type | Method and Description |
---|---|
static DetailAST |
annotatingWhat(DetailAST ast)
Checks to see what the passed in AST (representing
an annotation) is annotating.
|
static boolean |
containsAnnotation(DetailAST ast)
Checks to see if the AST is annotated with
any annotation.
|
static boolean |
containsAnnotation(DetailAST ast,
String annotation)
Checks to see if the AST is annotated with
the passed in annotation.
|
static DetailAST |
getAnnotation(DetailAST ast,
String annotation)
Checks to see if the AST is annotated with
the passed in annotation and return the AST
representing that annotation.
|
static DetailAST |
getAnnotationHolder(DetailAST ast)
Gets the AST that holds a series of annotations for the
potentially annotated AST.
|
static boolean |
isAnnotatingType(DetailAST ast,
int tokenType)
Checks to see if the passed in AST (representing
an annotation) is annotating the passed in type.
|
public static boolean containsAnnotation(DetailAST ast, String annotation)
This method will not look for imports or package statements to detect the passed in annotation.
To check if an AST contains a passed in annotation taking into account fully-qualified names (ex: java.lang.Override, Override) this method will need to be called twice. Once for each name given.
ast
- the current nodeannotation
- the annotation name to check forNullPointerException
- if the ast or
annotation is nullpublic static boolean containsAnnotation(DetailAST ast)
ast
- the current nodeNullPointerException
- if the ast is nullpublic static DetailAST getAnnotationHolder(DetailAST ast)
null
the passed in AST is not have an Annotation Holder.ast
- the current nodeNullPointerException
- if the ast is nullpublic static DetailAST getAnnotation(DetailAST ast, String annotation)
This method will not look for imports or package statements to detect the passed in annotation.
To check if an AST contains a passed in annotation taking into account fully-qualified names (ex: java.lang.Override, Override) this method will need to be called twice. Once for each name given.
ast
- the current nodeannotation
- the annotation name to check forNullPointerException
- if the ast or
annotation is nullpublic static DetailAST annotatingWhat(DetailAST ast)
ast
- the AST representing an annotation.NullPointerException
- if the ast is nullIllegalArgumentException
- if the ast is not
an TokenTypes.ANNOTATION
public static boolean isAnnotatingType(DetailAST ast, int tokenType)
ast
- the AST representing an annotationtokenType
- the passed in typeNullPointerException
- if the ast is nullIllegalArgumentException
- if the ast is not
an TokenTypes.ANNOTATION
Copyright © 2001–2015. All rights reserved.