public final class MethodDeclaration extends CallableDeclaration<MethodDeclaration> implements NodeWithType<MethodDeclaration,Type>, NodeWithOptionalBlockStmt<MethodDeclaration>, NodeWithModifiers<MethodDeclaration>, NodeWithJavadoc<MethodDeclaration>, NodeWithDeclaration, NodeWithSimpleName<MethodDeclaration>, NodeWithParameters<MethodDeclaration>, NodeWithThrownExceptions<MethodDeclaration>, NodeWithTypeParameters<MethodDeclaration>
class X { public int abc() {return 1;}
}
Node.ObserverRegistrationMode
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
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) |
MethodDeclaration(EnumSet<Modifier> modifiers,
String name,
Type type,
NodeList<Parameter> parameters) |
MethodDeclaration(EnumSet<Modifier> modifiers,
Type type,
String name) |
MethodDeclaration(Range range,
EnumSet<Modifier> modifiers,
NodeList<AnnotationExpr> annotations,
NodeList<TypeParameter> typeParameters,
Type type,
SimpleName name,
boolean isDefault,
NodeList<Parameter> parameters,
NodeList<ReferenceType> thrownExceptions,
BlockStmt body) |
appendThrowsIfRequested, getDeclarationAsString, getDeclarationAsString, getModifiers, getName, getParameters, getThrownExceptions, getTypeParameters
getAnnotations, setAnnotations
addOrphanComment, containsWithin, equals, getAllContainedComments, getBegin, getChildNodes, getComment, getData, getEnd, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getRange, hasComment, hashCode, isPositionedAfter, isPositionedBefore, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeOrphanComment, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
finalize, getClass, notify, notifyAll, wait, wait, wait
setType, setType, tryAddImportToParentCompilationUnit
createBody
addModifier, getModifiers, isAbstract, isFinal, isNative, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized, isTransient, isVolatile
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment
getDeclarationAsString, getDeclarationAsString
getName, getNameAsString, setName
addAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, getParameters, hasParametersOfType, hasParametersOfType, setParameter
addThrownException, addThrownException, getThrownException, getThrownExceptions, isThrown, isThrown, tryAddImportToParentCompilationUnit
addTypeParameter, getTypeParameter, getTypeParameters, isGeneric, setTypeParameter
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation
getAncestorOfType, setAsParentNodeOf, setAsParentNodeOf
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, boolean isDefault, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
public MethodDeclaration(Range range, EnumSet<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, Type type, SimpleName name, boolean isDefault, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, BlockStmt body)
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)public <A> void accept(VoidVisitor<A> v, A arg)
Visitable
public 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()
NodeWithType
getType
in interface NodeWithType<MethodDeclaration,Type>
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 boolean isDefault()
public MethodDeclaration setDefault(boolean isDefault)
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 List<NodeList<?>> getNodeLists()
Node
getNodeLists
in class CallableDeclaration<MethodDeclaration>
public boolean remove(Node node)
remove
in class CallableDeclaration<MethodDeclaration>
public MethodDeclaration removeBody()
public MethodDeclaration clone()
clone
in class CallableDeclaration<MethodDeclaration>
public MethodDeclarationMetaModel getMetaModel()
getMetaModel
in class CallableDeclaration<MethodDeclaration>
Copyright © 2007–2017. All rights reserved.