Package com.github.javaparser.ast.body
Class FieldDeclaration
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.body.BodyDeclaration<FieldDeclaration>
-
- com.github.javaparser.ast.body.FieldDeclaration
-
- All Implemented Interfaces:
NodeWithAccessModifiers<FieldDeclaration>,NodeWithFinalModifier<FieldDeclaration>,NodeWithPrivateModifier<FieldDeclaration>,NodeWithProtectedModifier<FieldDeclaration>,NodeWithPublicModifier<FieldDeclaration>,NodeWithStaticModifier<FieldDeclaration>,NodeWithAnnotations<FieldDeclaration>,NodeWithJavadoc<FieldDeclaration>,NodeWithModifiers<FieldDeclaration>,NodeWithRange<Node>,NodeWithTokenRange<Node>,NodeWithVariables<FieldDeclaration>,Observable,Visitable,HasParentNode<Node>,Cloneable
public final class FieldDeclaration extends BodyDeclaration<FieldDeclaration> implements NodeWithJavadoc<FieldDeclaration>, NodeWithVariables<FieldDeclaration>, NodeWithAccessModifiers<FieldDeclaration>, NodeWithStaticModifier<FieldDeclaration>, NodeWithFinalModifier<FieldDeclaration>
The declaration of a field in a class. "private static int a=15*15;" in this example:class X { private static int a=15*15; }- Author:
- Julio Vilmar Gesser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.ObserverRegistrationMode, Node.Parsedness
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
-
-
Constructor Summary
Constructors Constructor Description FieldDeclaration()FieldDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<VariableDeclarator> variables)This constructor is used by the parser and is considered private.FieldDeclaration(EnumSet<Modifier> modifiers, VariableDeclarator variable)FieldDeclaration(EnumSet<Modifier> modifiers, NodeList<VariableDeclarator> variables)FieldDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<VariableDeclarator> variables)FieldDeclaration(EnumSet<Modifier> modifiers, Type type, String name)Creates aFieldDeclaration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,A>
Raccept(GenericVisitor<R,A> v, A arg)Accept method for visitor support.<A> voidaccept(VoidVisitor<A> v, A arg)Accept method for visitor support.FieldDeclarationclone()MethodDeclarationcreateGetter()Create a getter for this field, will only work if this field declares only 1 identifier and if this field is already added to a ClassOrInterfaceDeclarationMethodDeclarationcreateSetter()Create a setter for this field, will only work if this field declares only 1 identifier and if this field is already added to a ClassOrInterfaceDeclarationFieldDeclarationMetaModelgetMetaModel()EnumSet<Modifier>getModifiers()Return the modifiers of this member declaration.List<NodeList<?>>getNodeLists()The list of NodeLists owned by this node.NodeList<VariableDeclarator>getVariables()booleanisTransient()booleanisVolatile()booleanremove(Node node)booleanreplace(Node node, Node replacementNode)FieldDeclarationsetModifiers(EnumSet<Modifier> modifiers)FieldDeclarationsetTransient(boolean set)FieldDeclarationsetVariables(NodeList<VariableDeclarator> variables)FieldDeclarationsetVolatile(boolean set)-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
getAnnotations, setAnnotations
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, customInitialization, equals, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
getAncestorOfType
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithFinalModifier
isFinal, setFinal
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, removeModifier, setModifier
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivate
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtected
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStatic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithVariables
addVariable, getCommonType, getElementType, getMaximumCommonType, getVariable, setVariable
-
-
-
-
Constructor Detail
-
FieldDeclaration
public FieldDeclaration()
-
FieldDeclaration
public FieldDeclaration(EnumSet<Modifier> modifiers, VariableDeclarator variable)
-
FieldDeclaration
public FieldDeclaration(EnumSet<Modifier> modifiers, NodeList<VariableDeclarator> variables)
-
FieldDeclaration
public FieldDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<VariableDeclarator> variables)
-
FieldDeclaration
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator") public FieldDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<VariableDeclarator> variables)
This constructor is used by the parser and is considered private.
-
FieldDeclaration
public FieldDeclaration(EnumSet<Modifier> modifiers, Type type, String name)
Creates aFieldDeclaration.- Parameters:
modifiers- modifierstype- typename- field name
-
-
Method Detail
-
accept
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Description copied from interface:VisitableAccept method for visitor support.- Specified by:
acceptin interfaceVisitable- Type Parameters:
R- the type of the return value of the visitorA- the type the user argument passed to the visitor- Parameters:
v- the visitor implementationarg- the argument passed to the visitor (of type A)- Returns:
- the result of the visit (of type R)
-
accept
public <A> void accept(VoidVisitor<A> v, A arg)
Description copied from interface:VisitableAccept method for visitor support.
-
getModifiers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public EnumSet<Modifier> getModifiers()
Return the modifiers of this member declaration.- Specified by:
getModifiersin interfaceNodeWithModifiers<FieldDeclaration>- Returns:
- modifiers
- See Also:
Modifier
-
getVariables
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NodeList<VariableDeclarator> getVariables()
- Specified by:
getVariablesin interfaceNodeWithVariables<FieldDeclaration>
-
setModifiers
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public FieldDeclaration setModifiers(EnumSet<Modifier> modifiers)
- Specified by:
setModifiersin interfaceNodeWithModifiers<FieldDeclaration>
-
setVariables
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public FieldDeclaration setVariables(NodeList<VariableDeclarator> variables)
- Specified by:
setVariablesin interfaceNodeWithVariables<FieldDeclaration>
-
createGetter
public MethodDeclaration createGetter()
Create a getter for this field, will only work if this field declares only 1 identifier and if this field is already added to a ClassOrInterfaceDeclaration- Returns:
- the
MethodDeclarationcreated - Throws:
IllegalStateException- if there is more than 1 variable identifier or if this field isn't attached to a class or enum
-
createSetter
public MethodDeclaration createSetter()
Create a setter for this field, will only work if this field declares only 1 identifier and if this field is already added to a ClassOrInterfaceDeclaration- Returns:
- the
MethodDeclarationcreated - Throws:
IllegalStateException- if there is more than 1 variable identifier or if this field isn't attached to a class or enum
-
isTransient
public boolean isTransient()
-
isVolatile
public boolean isVolatile()
-
setTransient
public FieldDeclaration setTransient(boolean set)
-
setVolatile
public FieldDeclaration setVolatile(boolean set)
-
getNodeLists
@Generated("com.github.javaparser.generator.core.node.GetNodeListsGenerator") public List<NodeList<?>> getNodeLists()
Description copied from class:NodeThe list of NodeLists owned by this node.- Overrides:
getNodeListsin classBodyDeclaration<FieldDeclaration>
-
remove
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
- Overrides:
removein classBodyDeclaration<FieldDeclaration>
-
clone
@Generated("com.github.javaparser.generator.core.node.CloneGenerator") public FieldDeclaration clone()
- Overrides:
clonein classBodyDeclaration<FieldDeclaration>
-
getMetaModel
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator") public FieldDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModelin classBodyDeclaration<FieldDeclaration>- Returns:
- get JavaParser specific node introspection information.
-
replace
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
- Overrides:
replacein classBodyDeclaration<FieldDeclaration>
-
-