Package com.github.javaparser.ast.expr
Class AnnotationExpr
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.expr.Expression
-
- com.github.javaparser.ast.expr.AnnotationExpr
-
- All Implemented Interfaces:
NodeWithName<AnnotationExpr>
,NodeWithRange<Node>
,NodeWithTokenRange<Node>
,Observable
,Visitable
,HasParentNode<Node>
,Resolvable<ResolvedAnnotationDeclaration>
,Cloneable
- Direct Known Subclasses:
MarkerAnnotationExpr
,NormalAnnotationExpr
,SingleMemberAnnotationExpr
public abstract class AnnotationExpr extends Expression implements NodeWithName<AnnotationExpr>, Resolvable<ResolvedAnnotationDeclaration>
A base class for the different types of annotations.- Author:
- Julio Vilmar Gesser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
-
-
Field Summary
Fields Modifier and Type Field Description protected Name
name
-
Fields inherited from class com.github.javaparser.ast.expr.Expression
EXCLUDE_ENCLOSED_EXPR, IS_NOT_ENCLOSED_EXPR
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY
-
-
Constructor Summary
Constructors Constructor Description AnnotationExpr()
AnnotationExpr(Name name)
AnnotationExpr(TokenRange tokenRange, Name name)
This constructor is used by the parser and is considered private.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationExpr
asAnnotationExpr()
AnnotationExpr
clone()
AnnotationExprMetaModel
getMetaModel()
Name
getName()
void
ifAnnotationExpr(Consumer<AnnotationExpr> action)
boolean
isAnnotationExpr()
boolean
replace(Node node, Node replacementNode)
ResolvedAnnotationDeclaration
resolve()
Attempts to resolve the declaration corresponding to the annotation expression.AnnotationExpr
setName(Name name)
Optional<AnnotationExpr>
toAnnotationExpr()
-
Methods inherited from class com.github.javaparser.ast.expr.Expression
appearsInAssignmentContext, appearsInInvocationContext, asArrayAccessExpr, asArrayCreationExpr, asArrayInitializerExpr, asAssignExpr, asBinaryExpr, asBooleanLiteralExpr, asCastExpr, asCharLiteralExpr, asClassExpr, asConditionalExpr, asDoubleLiteralExpr, asEnclosedExpr, asFieldAccessExpr, asInstanceOfExpr, asIntegerLiteralExpr, asLambdaExpr, asLiteralExpr, asLiteralStringValueExpr, asLongLiteralExpr, asMarkerAnnotationExpr, asMethodCallExpr, asMethodReferenceExpr, asNameExpr, asNormalAnnotationExpr, asNullLiteralExpr, asObjectCreationExpr, asPatternExpr, asRecordPatternExpr, asSingleMemberAnnotationExpr, asStringLiteralExpr, asSuperExpr, asSwitchExpr, asTextBlockLiteralExpr, asThisExpr, asTypeExpr, asTypePatternExpr, asUnaryExpr, asVariableDeclarationExpr, calculateResolvedType, elidesTypeArguments, ifArrayAccessExpr, ifArrayCreationExpr, ifArrayInitializerExpr, ifAssignExpr, ifBinaryExpr, ifBooleanLiteralExpr, ifCastExpr, ifCharLiteralExpr, ifClassExpr, ifConditionalExpr, ifDoubleLiteralExpr, ifEnclosedExpr, ifFieldAccessExpr, ifInstanceOfExpr, ifIntegerLiteralExpr, ifLambdaExpr, ifLiteralExpr, ifLiteralStringValueExpr, ifLongLiteralExpr, ifMarkerAnnotationExpr, ifMethodCallExpr, ifMethodReferenceExpr, ifNameExpr, ifNormalAnnotationExpr, ifNullLiteralExpr, ifObjectCreationExpr, ifPatternExpr, ifRecordPatternExpr, ifSingleMemberAnnotationExpr, ifStringLiteralExpr, ifSuperExpr, ifSwitchExpr, ifTextBlockLiteralExpr, ifThisExpr, ifTypeExpr, ifTypePatternExpr, ifUnaryExpr, ifVariableDeclarationExpr, isArrayAccessExpr, isArrayCreationExpr, isArrayInitializerExpr, isAssignExpr, isAssignmentContext, isBinaryExpr, isBooleanLiteralExpr, isCastExpr, isCharLiteralExpr, isClassExpr, isConditionalExpr, isDoubleLiteralExpr, isEnclosedExpr, isFieldAccessExpr, isInstanceOfExpr, isIntegerLiteralExpr, isInvocationContext, isLambdaExpr, isLiteralExpr, isLiteralStringValueExpr, isLongLiteralExpr, isMarkerAnnotationExpr, isMethodCallExpr, isMethodReferenceExpr, isNameExpr, isNormalAnnotationExpr, isNullLiteralExpr, isObjectCreationExpr, isPatternExpr, isPolyExpression, isQualified, isRecordPatternExpr, isSingleMemberAnnotationExpr, isStandaloneExpression, isStringLiteralExpr, isSuperExpr, isSwitchExpr, isTextBlockLiteralExpr, isThisExpr, isTypeExpr, isTypePatternExpr, isUnaryExpr, isVariableDeclarationExpr, toArrayAccessExpr, toArrayCreationExpr, toArrayInitializerExpr, toAssignExpr, toBinaryExpr, toBooleanLiteralExpr, toCastExpr, toCharLiteralExpr, toClassExpr, toConditionalExpr, toDoubleLiteralExpr, toEnclosedExpr, toFieldAccessExpr, toInstanceOfExpr, toIntegerLiteralExpr, toLambdaExpr, toLiteralExpr, toLiteralStringValueExpr, toLongLiteralExpr, toMarkerAnnotationExpr, toMethodCallExpr, toMethodReferenceExpr, toNameExpr, toNormalAnnotationExpr, toNullLiteralExpr, toObjectCreationExpr, toPatternExpr, toRecordPatternExpr, toSingleMemberAnnotationExpr, toStringLiteralExpr, toSuperExpr, toSwitchExpr, toTextBlockLiteralExpr, toThisExpr, toTypeExpr, toTypePatternExpr, toUnaryExpr, toVariableDeclarationExpr
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findByRange, findCompilationUnit, findData, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOf
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithName
getNameAsString, setName
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRange
-
-
-
-
Field Detail
-
name
protected Name name
-
-
Constructor Detail
-
AnnotationExpr
public AnnotationExpr()
-
AnnotationExpr
public AnnotationExpr(Name name)
-
AnnotationExpr
public AnnotationExpr(TokenRange tokenRange, Name name)
This constructor is used by the parser and is considered private.
-
-
Method Detail
-
getName
public Name getName()
- Specified by:
getName
in interfaceNodeWithName<AnnotationExpr>
-
setName
public AnnotationExpr setName(Name name)
- Specified by:
setName
in interfaceNodeWithName<AnnotationExpr>
-
clone
public AnnotationExpr clone()
- Overrides:
clone
in classExpression
-
getMetaModel
public AnnotationExprMetaModel getMetaModel()
- Overrides:
getMetaModel
in classExpression
- Returns:
- get JavaParser specific node introspection information.
-
isAnnotationExpr
public boolean isAnnotationExpr()
- Overrides:
isAnnotationExpr
in classExpression
-
asAnnotationExpr
public AnnotationExpr asAnnotationExpr()
- Overrides:
asAnnotationExpr
in classExpression
-
ifAnnotationExpr
public void ifAnnotationExpr(Consumer<AnnotationExpr> action)
- Overrides:
ifAnnotationExpr
in classExpression
-
resolve
public ResolvedAnnotationDeclaration resolve()
Attempts to resolve the declaration corresponding to the annotation expression. If successful, aResolvedAnnotationDeclaration
representing the declaration of the annotation referenced by thisAnnotationExpr
is returned. Otherwise, anUnsolvedSymbolException
is thrown.- Specified by:
resolve
in interfaceResolvable<ResolvedAnnotationDeclaration>
- Returns:
- a
ResolvedAnnotationDeclaration
representing the declaration of the annotation expression. - Throws:
UnsolvedSymbolException
- if the declaration corresponding to the annotation expression could not be resolved.
-
toAnnotationExpr
public Optional<AnnotationExpr> toAnnotationExpr()
- Overrides:
toAnnotationExpr
in classExpression
-
-