Interface NodeWithAnnotations<N extends Node>
-
- All Known Implementing Classes:
AnnotationDeclaration
,AnnotationMemberDeclaration
,ArrayCreationLevel
,ArrayType
,BodyDeclaration
,CallableDeclaration
,ClassOrInterfaceDeclaration
,ClassOrInterfaceType
,CompactConstructorDeclaration
,ConstructorDeclaration
,EnumConstantDeclaration
,EnumDeclaration
,FieldDeclaration
,InitializerDeclaration
,IntersectionType
,MethodDeclaration
,ModuleDeclaration
,PackageDeclaration
,Parameter
,PrimitiveType
,ReceiverParameter
,RecordDeclaration
,TypeDeclaration
,TypeParameter
,UnionType
,VariableDeclarationExpr
,VoidType
,WildcardType
public interface NodeWithAnnotations<N extends Node>
A node that can be annotated.- Since:
- July 2014
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default NormalAnnotationExpr
addAndGetAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this node and automatically add the importdefault NormalAnnotationExpr
addAndGetAnnotation(java.lang.String name)
Annotates thisdefault N
addAnnotation(AnnotationExpr element)
default N
addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this node and automatically add the importdefault N
addAnnotation(java.lang.String name)
Annotates thisdefault N
addMarkerAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this with a marker annotation and automatically add the importdefault N
addMarkerAnnotation(java.lang.String name)
Annotates this with a marker annotationdefault N
addSingleMemberAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, Expression expression)
Annotates this with a single member annotationdefault N
addSingleMemberAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, java.lang.String value)
Annotates this with a single member annotation and automatically add the importdefault N
addSingleMemberAnnotation(java.lang.String name, Expression expression)
Annotates this with a single member annotationdefault N
addSingleMemberAnnotation(java.lang.String name, java.lang.String value)
Annotates this with a single member annotationdefault AnnotationExpr
getAnnotation(int i)
default java.util.Optional<AnnotationExpr>
getAnnotationByClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Try to find an annotation by its classdefault java.util.Optional<AnnotationExpr>
getAnnotationByName(java.lang.String annotationName)
Try to find an annotation by its nameNodeList<AnnotationExpr>
getAnnotations()
default boolean
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Check whether an annotation with this class is present on this elementdefault boolean
isAnnotationPresent(java.lang.String annotationName)
Check whether an annotation with this name is present on this elementdefault N
setAnnotation(int i, AnnotationExpr element)
N
setAnnotations(NodeList<AnnotationExpr> annotations)
void
tryAddImportToParentCompilationUnit(java.lang.Class<?> clazz)
-
-
-
Method Detail
-
getAnnotations
NodeList<AnnotationExpr> getAnnotations()
-
setAnnotations
N setAnnotations(NodeList<AnnotationExpr> annotations)
-
tryAddImportToParentCompilationUnit
void tryAddImportToParentCompilationUnit(java.lang.Class<?> clazz)
-
getAnnotation
default AnnotationExpr getAnnotation(int i)
-
setAnnotation
default N setAnnotation(int i, AnnotationExpr element)
-
addAnnotation
default N addAnnotation(AnnotationExpr element)
-
addAnnotation
default N addAnnotation(java.lang.String name)
Annotates this- Parameters:
name
- the name of the annotation- Returns:
- this
-
addAndGetAnnotation
default NormalAnnotationExpr addAndGetAnnotation(java.lang.String name)
Annotates this- Parameters:
name
- the name of the annotation- Returns:
- the
NormalAnnotationExpr
added
-
addAnnotation
default N addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this node and automatically add the import- Parameters:
clazz
- the class of the annotation- Returns:
- this
-
addAndGetAnnotation
default NormalAnnotationExpr addAndGetAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this node and automatically add the import- Parameters:
clazz
- the class of the annotation- Returns:
- the
NormalAnnotationExpr
added
-
addMarkerAnnotation
default N addMarkerAnnotation(java.lang.String name)
Annotates this with a marker annotation- Parameters:
name
- the name of the annotation- Returns:
- this
-
addMarkerAnnotation
default N addMarkerAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Annotates this with a marker annotation and automatically add the import- Parameters:
clazz
- the class of the annotation- Returns:
- this
-
addSingleMemberAnnotation
default N addSingleMemberAnnotation(java.lang.String name, Expression expression)
Annotates this with a single member annotation- Parameters:
name
- the name of the annotationexpression
- the part between ()- Returns:
- this
-
addSingleMemberAnnotation
default N addSingleMemberAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, Expression expression)
Annotates this with a single member annotation- Parameters:
clazz
- the class of the annotationexpression
- the part between ()- Returns:
- this
-
addSingleMemberAnnotation
default N addSingleMemberAnnotation(java.lang.String name, java.lang.String value)
Annotates this with a single member annotation- Parameters:
name
- the name of the annotationvalue
- the value, don't forget to add \"\" for a string value- Returns:
- this
-
addSingleMemberAnnotation
default N addSingleMemberAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz, java.lang.String value)
Annotates this with a single member annotation and automatically add the import- Parameters:
clazz
- the class of the annotationvalue
- the value, don't forget to add \"\" for a string value- Returns:
- this
-
isAnnotationPresent
default boolean isAnnotationPresent(java.lang.String annotationName)
Check whether an annotation with this name is present on this element- Parameters:
annotationName
- the name of the annotation- Returns:
- true if found, false if not
-
isAnnotationPresent
default boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Check whether an annotation with this class is present on this element- Parameters:
annotationClass
- the class of the annotation- Returns:
- true if found, false if not
-
getAnnotationByName
default java.util.Optional<AnnotationExpr> getAnnotationByName(java.lang.String annotationName)
Try to find an annotation by its name- Parameters:
annotationName
- the name of the annotation
-
getAnnotationByClass
default java.util.Optional<AnnotationExpr> getAnnotationByClass(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Try to find an annotation by its class- Parameters:
annotationClass
- the class of the annotation
-
-