public class MethodDeclaration extends CallableDeclaration<MethodDeclaration> implements NodeWithType<MethodDeclaration,Type>, NodeWithOptionalBlockStmt<MethodDeclaration>, NodeWithJavadoc<MethodDeclaration>, NodeWithDeclaration, NodeWithSimpleName<MethodDeclaration>, NodeWithParameters<MethodDeclaration>, NodeWithThrownExceptions<MethodDeclaration>, NodeWithTypeParameters<MethodDeclaration>, NodeWithAccessModifiers<MethodDeclaration>, NodeWithAbstractModifier<MethodDeclaration>, NodeWithStaticModifier<MethodDeclaration>, NodeWithFinalModifier<MethodDeclaration>, NodeWithStrictfpModifier<MethodDeclaration>, Resolvable<ResolvedMethodDeclaration>
class X { public int abc() {return 1;}
}
All annotations preceding the return type will be set on this object, not on the return type.
JavaParser doesn't know if it they are applicable to the method or the type.
CallableDeclaration.SignatureNode.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversalABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEYappendThrowsIfRequested, asCallableDeclaration, getModifiers, getName, getParameters, getReceiverParameter, getSignature, getThrownExceptions, getTypeParameters, ifCallableDeclaration, isCallableDeclaration, isFixedArityMethod, isVariableArityMethod, removeReceiverParameter, setReceiverParameter, toCallableDeclarationasAnnotationDeclaration, asAnnotationMemberDeclaration, asClassOrInterfaceDeclaration, asCompactConstructorDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asRecordDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifClassOrInterfaceDeclaration, ifCompactConstructorDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifRecordDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isClassOrInterfaceDeclaration, isCompactConstructorDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isRecordDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toClassOrInterfaceDeclaration, toCompactConstructorDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toRecordDeclaration, toTypeDeclarationaddOrphanComment, 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, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walkfinalize, getClass, notify, notifyAll, wait, wait, waitgetTypeAsString, setType, setType, tryAddImportToParentCompilationUnitcreateBodygetComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocCommentgetDeclarationAsString, getDeclarationAsStringgetName, getNameAsExpression, getNameAsString, setNameaddAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, getParameters, hasParametersOfType, hasParametersOfType, setParameter, tryAddImportToParentCompilationUnitaddThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnitaddTypeParameter, addTypeParameter, getTypeParameter, getTypeParameters, isGeneric, setTypeParametersetPublicisPrivate, setPrivateisProtected, setProtectedaddModifier, getAccessSpecifier, getModifiers, hasModifier, removeModifier, setModifier, setModifierssetAbstractisStatic, setStaticisFinal, setFinalisStrictfp, setStrictfpaddAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnitfindAncestor, findAncestor, findAncestor, hasParentNode, isDescendantOfcontainsWithin, containsWithinRange, getBegin, getEnd, hasRangepublic MethodDeclaration()
public MethodDeclaration(NodeList<Modifier> modifiers, String name, Type type, NodeList<Parameter> parameters)
public MethodDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
public MethodDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
public MethodDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitableaccept in interface VisitableR - the type of the return value of the visitorA - the type the user argument passed to the visitorv - the visitor implementationarg - the argument passed to the visitor (of type A)public <A> void accept(VoidVisitor<A> v, A arg)
Visitablepublic Optional<BlockStmt> getBody()
getBody in interface NodeWithOptionalBlockStmt<MethodDeclaration>public MethodDeclaration setBody(BlockStmt body)
setBody in interface NodeWithOptionalBlockStmt<MethodDeclaration>body - the body, can be nullpublic Type getType()
NodeWithTypegetType in interface NodeWithType<MethodDeclaration,Type>public MethodDeclaration setType(Type type)
NodeWithTypesetType in interface NodeWithType<MethodDeclaration,Type>type - the typepublic MethodDeclaration setModifiers(NodeList<Modifier> modifiers)
setModifiers in interface NodeWithModifiers<MethodDeclaration>setModifiers in class CallableDeclaration<MethodDeclaration>public MethodDeclaration setName(SimpleName name)
setName in interface NodeWithSimpleName<MethodDeclaration>setName in class CallableDeclaration<MethodDeclaration>public MethodDeclaration setParameters(NodeList<Parameter> parameters)
setParameters in interface NodeWithParameters<MethodDeclaration>setParameters in class CallableDeclaration<MethodDeclaration>public MethodDeclaration setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
setThrownExceptions in interface NodeWithThrownExceptions<MethodDeclaration>setThrownExceptions in class CallableDeclaration<MethodDeclaration>public MethodDeclaration setTypeParameters(NodeList<TypeParameter> typeParameters)
setTypeParameters in interface NodeWithTypeParameters<MethodDeclaration>setTypeParameters in class CallableDeclaration<MethodDeclaration>public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)
[accessSpecifier] [static] [abstract] [final] [native] [synchronized] returnType methodName ([paramType [paramName]]) [throws exceptionsList]
getDeclarationAsString in interface NodeWithDeclarationincludingModifiers - flag to include the modifiers (if present) in the string producedincludingThrows - flag to include the throws clause (if present) in the string producedincludingParameterName - flag to include the parameter name (while the parameter type is always included) in
the string producedpublic String toDescriptor()
public boolean isPublic()
isPublic in interface NodeWithPublicModifier<MethodDeclaration>public boolean isAbstract()
isAbstract in interface NodeWithAbstractModifier<MethodDeclaration>public boolean isNative()
public boolean isSynchronized()
public boolean isDefault()
public MethodDeclaration setNative(boolean set)
public MethodDeclaration setSynchronized(boolean set)
public MethodDeclaration setDefault(boolean set)
public boolean remove(Node node)
remove in class CallableDeclaration<MethodDeclaration>public MethodDeclaration removeBody()
removeBody in interface NodeWithOptionalBlockStmt<MethodDeclaration>public MethodDeclaration clone()
clone in class CallableDeclaration<MethodDeclaration>public MethodDeclarationMetaModel getMetaModel()
getMetaModel in class CallableDeclaration<MethodDeclaration>public boolean replace(Node node, Node replacementNode)
replace in class CallableDeclaration<MethodDeclaration>public boolean isMethodDeclaration()
isMethodDeclaration in class BodyDeclaration<MethodDeclaration>public MethodDeclaration asMethodDeclaration()
asMethodDeclaration in class BodyDeclaration<MethodDeclaration>public void ifMethodDeclaration(Consumer<MethodDeclaration> action)
ifMethodDeclaration in class BodyDeclaration<MethodDeclaration>public ResolvedMethodDeclaration resolve()
resolve in interface Resolvable<ResolvedMethodDeclaration>public Optional<MethodDeclaration> toMethodDeclaration()
toMethodDeclaration in class BodyDeclaration<MethodDeclaration>Copyright © 2007–2024. All rights reserved.