public final 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;}
}
CallableDeclaration.Signature
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, SYMBOL_RESOLVER_KEY
Constructor and Description |
---|
MethodDeclaration() |
MethodDeclaration(EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters,
Type type,
SimpleName name,
boolean isDefault,
NodeList<Parameter> parameters,
NodeList<ReferenceType> thrownExceptions,
BlockStmt body)
Deprecated.
this constructor allows you to set "isDefault", but this is no longer a field of this node, but simply one of the modifiers. Use setDefault(boolean) or add DEFAULT to the modifiers set.
|
MethodDeclaration(EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters,
Type type,
SimpleName name,
NodeList<Parameter> parameters,
NodeList<ReferenceType> thrownExceptions,
BlockStmt body) |
MethodDeclaration(EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters,
Type type,
SimpleName name,
NodeList<Parameter> parameters,
NodeList<ReferenceType> thrownExceptions,
BlockStmt body,
ReceiverParameter receiverParameter) |
MethodDeclaration(EnumSet<Modifier> modifiers,
String name,
Type type,
NodeList<Parameter> parameters) |
MethodDeclaration(EnumSet<Modifier> modifiers,
Type type,
String name) |
MethodDeclaration(TokenRange tokenRange,
EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters,
Type type,
SimpleName name,
NodeList<Parameter> parameters,
NodeList<ReferenceType> thrownExceptions,
BlockStmt body,
ReceiverParameter receiverParameter)
This constructor is used by the parser and is considered private.
|
appendThrowsIfRequested, asCallableDeclaration, getDeclarationAsString, getDeclarationAsString, getModifiers, getName, getParameters, getReceiverParameter, getSignature, getThrownExceptions, getTypeParameters, ifCallableDeclaration, isCallableDeclaration, removeReceiverParameter, setReceiverParameter, toCallableDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asClassOrInterfaceDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifClassOrInterfaceDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isClassOrInterfaceDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toClassOrInterfaceDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toTypeDeclaration
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findParent, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
finalize, getClass, notify, notifyAll, wait, wait, wait
getTypeAsString, setType, setType, tryAddImportToParentCompilationUnit
createBody
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment
getDeclarationAsString, getDeclarationAsString
getName, getNameAsExpression, getNameAsString, setName
addAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, getParameters, hasParametersOfType, hasParametersOfType, setParameter, tryAddImportToParentCompilationUnit
addThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnit
addTypeParameter, getTypeParameter, getTypeParameters, isGeneric, setTypeParameter
isPublic, setPublic
isPrivate, setPrivate
isProtected, setProtected
addModifier, getModifiers, removeModifier, setModifier
isAbstract, setAbstract
isStatic, setStatic
isFinal, setFinal
isStrictfp, setStrictfp
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnit
getAncestorOfType
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
public MethodDeclaration()
public MethodDeclaration(EnumSet<Modifier> modifiers, String name, Type type, NodeList<Parameter> parameters)
public MethodDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
public MethodDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
@Deprecated public MethodDeclaration(EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, boolean isDefault, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
@Generated(value="com.github.javaparser.generator.core.node.MainConstructorGenerator") public MethodDeclaration(TokenRange tokenRange, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body, ReceiverParameter receiverParameter)
@Generated(value="com.github.javaparser.generator.core.node.AcceptGenerator") public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitable
accept
in interface Visitable
R
- 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)@Generated(value="com.github.javaparser.generator.core.node.AcceptGenerator") public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public Optional<BlockStmt> getBody()
getBody
in interface NodeWithOptionalBlockStmt<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public MethodDeclaration setBody(BlockStmt body)
setBody
in interface NodeWithOptionalBlockStmt<MethodDeclaration>
body
- the body, can be null@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public Type getType()
NodeWithType
getType
in interface NodeWithType<MethodDeclaration,Type>
@Generated(value="com.github.javaparser.generator.core.node.PropertyGenerator") public MethodDeclaration setType(Type type)
NodeWithType
setType
in interface NodeWithType<MethodDeclaration,Type>
type
- the typepublic MethodDeclaration setModifiers(EnumSet<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 NodeWithDeclaration
getDeclarationAsString
in class CallableDeclaration<MethodDeclaration>
includingModifiers
- 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 boolean isNative()
public boolean isSynchronized()
public boolean isDefault()
public MethodDeclaration setNative(boolean set)
public MethodDeclaration setSynchronized(boolean set)
public MethodDeclaration setDefault(boolean set)
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public boolean remove(Node node)
remove
in class CallableDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.RemoveMethodGenerator") public MethodDeclaration removeBody()
removeBody
in interface NodeWithOptionalBlockStmt<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.CloneGenerator") public MethodDeclaration clone()
clone
in class CallableDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.GetMetaModelGenerator") public MethodDeclarationMetaModel getMetaModel()
getMetaModel
in class CallableDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.ReplaceMethodGenerator") public boolean replace(Node node, Node replacementNode)
replace
in class CallableDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public boolean isMethodDeclaration()
isMethodDeclaration
in class BodyDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public MethodDeclaration asMethodDeclaration()
asMethodDeclaration
in class BodyDeclaration<MethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public void ifMethodDeclaration(Consumer<MethodDeclaration> action)
ifMethodDeclaration
in class BodyDeclaration<MethodDeclaration>
public ResolvedMethodDeclaration resolve()
resolve
in interface Resolvable<ResolvedMethodDeclaration>
@Generated(value="com.github.javaparser.generator.core.node.TypeCastingGenerator") public Optional<MethodDeclaration> toMethodDeclaration()
toMethodDeclaration
in class BodyDeclaration<MethodDeclaration>
Copyright © 2007–2018. All rights reserved.