Top Description Methods
com.github.javaparser.ast.nodeTypes

public Interface NodeWithAnnotations<N extends Node>

Known Direct Implementers
com.github.javaparser.ast.type.ArrayType, com.github.javaparser.ast.type.ClassOrInterfaceType, com.github.javaparser.ast.type.IntersectionType, com.github.javaparser.ast.type.PrimitiveType, com.github.javaparser.ast.type.TypeParameter, com.github.javaparser.ast.type.UnionType, com.github.javaparser.ast.type.VoidType, com.github.javaparser.ast.type.WildcardType, com.github.javaparser.ast.ArrayCreationLevel, com.github.javaparser.ast.PackageDeclaration, com.github.javaparser.ast.body.BodyDeclaration, com.github.javaparser.ast.body.Parameter, com.github.javaparser.ast.body.ReceiverParameter, com.github.javaparser.ast.expr.VariableDeclarationExpr, com.github.javaparser.ast.modules.ModuleDeclaration
Imports
com.github.javaparser.ast.Node, .NodeList, com.github.javaparser.ast.expr.*, java.lang.annotation.Annotation, java.util.Optional

A node that can be annotated.
Author
Federico Tomassetti
Since
July 2014

Method Summary

Modifier and TypeMethod and Description
public default NormalAnnotationExpr

Returns:

the NormalAnnotationExpr added
addAndGetAnnotation
(String
the name of the annotation
name
)

Annotates this

public default NormalAnnotationExpr

Returns:

the NormalAnnotationExpr added
addAndGetAnnotation
(Class<? extends Annotation>
the class of the annotation
clazz
)

Annotates this node and automatically add the import

public default N
public default N

Returns:

this
addAnnotation
(String
the name of the annotation
name
)

Annotates this

public default N

Returns:

this
addAnnotation
(Class<? extends Annotation>
the class of the annotation
clazz
)

Annotates this node and automatically add the import

public default N

Returns:

this
addMarkerAnnotation
(String
the name of the annotation
name
)

Annotates this with a marker annotation

public default N

Returns:

this
addMarkerAnnotation
(Class<? extends Annotation>
the class of the annotation
clazz
)

Annotates this with a marker annotation and automatically add the import

public default N

Returns:

this
addSingleMemberAnnotation
(String
the name of the annotation
name
,
Expression
the part between ()
expression
)

Annotates this with a single member annotation

public default N

Returns:

this
addSingleMemberAnnotation
(Class<? extends Annotation>
the class of the annotation
clazz
,
Expression
the part between ()
expression
)

Annotates this with a single member annotation

public default N

Returns:

this
addSingleMemberAnnotation
(String
the name of the annotation
name
,
String
the value, don't forget to add \"\" for a string value
value
)

Annotates this with a single member annotation

public default N

Returns:

this
addSingleMemberAnnotation
(Class<? extends Annotation>
the class of the annotation
clazz
,
String
the value, don't forget to add \"\" for a string value
value
)

Annotates this with a single member annotation and automatically add the import

public default AnnotationExpr
public default Optional<AnnotationExpr>
getAnnotationByClass(Class<? extends Annotation>
the class of the annotation
annotationClass
)

Try to find an annotation by its class

public default Optional<AnnotationExpr>
getAnnotationByName(String
the name of the annotation
annotationName
)

Try to find an annotation by its name

public NodeList<AnnotationExpr>
public default boolean

Returns:

true if found, false if not
isAnnotationPresent
(String
the name of the annotation
annotationName
)

Check whether an annotation with this name is present on this element

public default boolean

Returns:

true if found, false if not
isAnnotationPresent
(Class<? extends Annotation>
the class of the annotation
annotationClass
)

Check whether an annotation with this class is present on this element

public default N
setAnnotation(int i, AnnotationExpr element)

public N
public void

Method Detail

addAndGetAnnotationback to summary
public default NormalAnnotationExpr addAndGetAnnotation(String name)

Annotates this

Parameters
name:String

the name of the annotation

Returns:NormalAnnotationExpr

the NormalAnnotationExpr added

Annotations
@SuppressWarnings:unchecked
addAndGetAnnotationback to summary
public default NormalAnnotationExpr addAndGetAnnotation(Class<? extends Annotation> clazz)

Annotates this node and automatically add the import

Parameters
clazz:Class<? extends Annotation>

the class of the annotation

Returns:NormalAnnotationExpr

the NormalAnnotationExpr added

addAnnotationback to summary
public default N addAnnotation(AnnotationExpr element)
Annotations
@SuppressWarnings:unchecked
addAnnotationback to summary
public default N addAnnotation(String name)

Annotates this

Parameters
name:String

the name of the annotation

Returns:N

this

Annotations
@SuppressWarnings:unchecked
addAnnotationback to summary
public default N addAnnotation(Class<? extends Annotation> clazz)

Annotates this node and automatically add the import

Parameters
clazz:Class<? extends Annotation>

the class of the annotation

Returns:N

this

addMarkerAnnotationback to summary
public default N addMarkerAnnotation(String name)

Annotates this with a marker annotation

Parameters
name:String

the name of the annotation

Returns:N

this

Annotations
@SuppressWarnings:unchecked
addMarkerAnnotationback to summary
public default N addMarkerAnnotation(Class<? extends Annotation> clazz)

Annotates this with a marker annotation and automatically add the import

Parameters
clazz:Class<? extends Annotation>

the class of the annotation

Returns:N

this

addSingleMemberAnnotationback to summary
public default N addSingleMemberAnnotation(String name, Expression expression)

Annotates this with a single member annotation

Parameters
name:String

the name of the annotation

expression:Expression

the part between ()

Returns:N

this

Annotations
@SuppressWarnings:unchecked
addSingleMemberAnnotationback to summary
public default N addSingleMemberAnnotation(Class<? extends Annotation> clazz, Expression expression)

Annotates this with a single member annotation

Parameters
clazz:Class<? extends Annotation>

the class of the annotation

expression:Expression

the part between ()

Returns:N

this

addSingleMemberAnnotationback to summary
public default N addSingleMemberAnnotation(String name, String value)

Annotates this with a single member annotation

Parameters
name:String

the name of the annotation

value:String

the value, don't forget to add \"\" for a string value

Returns:N

this

addSingleMemberAnnotationback to summary
public default N addSingleMemberAnnotation(Class<? extends Annotation> clazz, String value)

Annotates this with a single member annotation and automatically add the import

Parameters
clazz:Class<? extends Annotation>

the class of the annotation

value:String

the value, don't forget to add \"\" for a string value

Returns:N

this

getAnnotationback to summary
public default AnnotationExpr getAnnotation(int i)
getAnnotationByClassback to summary
public default Optional<AnnotationExpr> getAnnotationByClass(Class<? extends Annotation> annotationClass)

Try to find an annotation by its class

Parameters
annotationClass:Class<? extends Annotation>

the class of the annotation

getAnnotationByNameback to summary
public default Optional<AnnotationExpr> getAnnotationByName(String annotationName)

Try to find an annotation by its name

Parameters
annotationName:String

the name of the annotation

getAnnotationsback to summary
public NodeList<AnnotationExpr> getAnnotations()
isAnnotationPresentback to summary
public default boolean isAnnotationPresent(String annotationName)

Check whether an annotation with this name is present on this element

Parameters
annotationName:String

the name of the annotation

Returns:boolean

true if found, false if not

isAnnotationPresentback to summary
public default boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)

Check whether an annotation with this class is present on this element

Parameters
annotationClass:Class<? extends Annotation>

the class of the annotation

Returns:boolean

true if found, false if not

setAnnotationback to summary
public default N setAnnotation(int i, AnnotationExpr element)
Annotations
@SuppressWarnings:unchecked
setAnnotationsback to summary
public N setAnnotations(NodeList<AnnotationExpr> annotations)
tryAddImportToParentCompilationUnitback to summary
public void tryAddImportToParentCompilationUnit(Class<?> clazz)