Package com.github.javaparser.ast.body
Class CallableDeclaration<T extends CallableDeclaration<?>>
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.body.BodyDeclaration<T>
-
- com.github.javaparser.ast.body.CallableDeclaration<T>
-
- All Implemented Interfaces:
NodeWithAbstractModifier<T>
,NodeWithAccessModifiers<T>
,NodeWithFinalModifier<T>
,NodeWithPrivateModifier<T>
,NodeWithProtectedModifier<T>
,NodeWithPublicModifier<T>
,NodeWithStaticModifier<T>
,NodeWithStrictfpModifier<T>
,NodeWithAnnotations<T>
,NodeWithDeclaration
,NodeWithJavadoc<T>
,NodeWithModifiers<T>
,NodeWithParameters<T>
,NodeWithRange<Node>
,NodeWithSimpleName<T>
,NodeWithThrownExceptions<T>
,NodeWithTokenRange<Node>
,NodeWithTypeParameters<T>
,Observable
,Visitable
,HasParentNode<Node>
,Cloneable
- Direct Known Subclasses:
ConstructorDeclaration
,MethodDeclaration
public abstract class CallableDeclaration<T extends CallableDeclaration<?>> extends BodyDeclaration<T> implements NodeWithAccessModifiers<T>, NodeWithDeclaration, NodeWithSimpleName<T>, NodeWithParameters<T>, NodeWithThrownExceptions<T>, NodeWithTypeParameters<T>, NodeWithJavadoc<T>, NodeWithAbstractModifier<T>, NodeWithStaticModifier<T>, NodeWithFinalModifier<T>, NodeWithStrictfpModifier<T>
Represents a declaration which is callable eg. a method or a constructor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CallableDeclaration.Signature
A method or constructor signature.-
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 inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, SYMBOL_RESOLVER_KEY
-
-
Constructor Summary
Constructors Constructor Description CallableDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, ReceiverParameter receiverParameter)
This constructor is used by the parser and is considered private.
-
Method Summary
-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asClassOrInterfaceDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asTypeDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifClassOrInterfaceDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifTypeDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isClassOrInterfaceDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isTypeDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toClassOrInterfaceDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toTypeDeclaration
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, hasComment, hashCode, 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, 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, findParent, getAncestorOfType
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAbstractModifier
isAbstract, setAbstract
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, 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, setJavadocComment
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiers
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithParameters
addAndGetParameter, addAndGetParameter, addAndGetParameter, addAndGetParameter, addParameter, addParameter, addParameter, addParameter, getParameter, getParameterByName, getParameterByType, getParameterByType, hasParametersOfType, hasParametersOfType, setParameter, tryAddImportToParentCompilationUnit
-
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.NodeWithSimpleName
getNameAsExpression, getNameAsString, setName
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStatic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfp
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions
addThrownException, addThrownException, getThrownException, isThrown, isThrown, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters
addTypeParameter, addTypeParameter, getTypeParameter, isGeneric, setTypeParameter
-
-
-
-
Constructor Detail
-
CallableDeclaration
public CallableDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, ReceiverParameter receiverParameter)
This constructor is used by the parser and is considered private.
-
-
Method Detail
-
getModifiers
public NodeList<Modifier> getModifiers()
Return the modifiers of this member declaration.- Specified by:
getModifiers
in interfaceNodeWithModifiers<T extends CallableDeclaration<?>>
- Returns:
- modifiers
- See Also:
Modifier
-
setModifiers
public T setModifiers(NodeList<Modifier> modifiers)
- Specified by:
setModifiers
in interfaceNodeWithModifiers<T extends CallableDeclaration<?>>
-
getName
public SimpleName getName()
- Specified by:
getName
in interfaceNodeWithSimpleName<T extends CallableDeclaration<?>>
-
setName
public T setName(SimpleName name)
- Specified by:
setName
in interfaceNodeWithSimpleName<T extends CallableDeclaration<?>>
-
getParameters
public NodeList<Parameter> getParameters()
- Specified by:
getParameters
in interfaceNodeWithParameters<T extends CallableDeclaration<?>>
-
setParameters
public T setParameters(NodeList<Parameter> parameters)
- Specified by:
setParameters
in interfaceNodeWithParameters<T extends CallableDeclaration<?>>
-
getThrownExceptions
public NodeList<ReferenceType> getThrownExceptions()
- Specified by:
getThrownExceptions
in interfaceNodeWithThrownExceptions<T extends CallableDeclaration<?>>
-
setThrownExceptions
public T setThrownExceptions(NodeList<ReferenceType> thrownExceptions)
- Specified by:
setThrownExceptions
in interfaceNodeWithThrownExceptions<T extends CallableDeclaration<?>>
-
getTypeParameters
public NodeList<TypeParameter> getTypeParameters()
- Specified by:
getTypeParameters
in interfaceNodeWithTypeParameters<T extends CallableDeclaration<?>>
-
setTypeParameters
public T setTypeParameters(NodeList<TypeParameter> typeParameters)
- Specified by:
setTypeParameters
in interfaceNodeWithTypeParameters<T extends CallableDeclaration<?>>
-
getDeclarationAsString
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows)
Description copied from interface:NodeWithDeclaration
AsNodeWithDeclaration.getDeclarationAsString(boolean, boolean, boolean)
including the parameters with both type and name.- Specified by:
getDeclarationAsString
in interfaceNodeWithDeclaration
- Parameters:
includingModifiers
- flag to include the modifiers (if present) in the string producedincludingThrows
- flag to include the throws clause (if present) in the string produced- Returns:
- String representation of declaration based on parameter flags
-
getDeclarationAsString
public String getDeclarationAsString()
Description copied from interface:NodeWithDeclaration
AsNodeWithDeclaration.getDeclarationAsString(boolean, boolean, boolean)
including the modifiers, the throws clause and the parameters with both type and name.- Specified by:
getDeclarationAsString
in interfaceNodeWithDeclaration
- Returns:
- String representation of declaration
-
getDeclarationAsString
public abstract String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName)
Description copied from interface:NodeWithDeclaration
A simple representation of the element declaration. It should fit one string.- Specified by:
getDeclarationAsString
in interfaceNodeWithDeclaration
- Parameters:
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 produced- Returns:
- String representation of declaration based on parameter flags
-
appendThrowsIfRequested
protected String appendThrowsIfRequested(boolean includingThrows)
-
remove
public boolean remove(Node node)
- Overrides:
remove
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
getSignature
public CallableDeclaration.Signature getSignature()
-
clone
public CallableDeclaration<?> clone()
- Overrides:
clone
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
getMetaModel
public CallableDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModel
in classBodyDeclaration<T extends CallableDeclaration<?>>
- Returns:
- get JavaParser specific node introspection information.
-
replace
public boolean replace(Node node, Node replacementNode)
- Overrides:
replace
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
isCallableDeclaration
public boolean isCallableDeclaration()
- Overrides:
isCallableDeclaration
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
asCallableDeclaration
public CallableDeclaration asCallableDeclaration()
- Overrides:
asCallableDeclaration
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
ifCallableDeclaration
public void ifCallableDeclaration(Consumer<CallableDeclaration> action)
- Overrides:
ifCallableDeclaration
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
getReceiverParameter
public Optional<ReceiverParameter> getReceiverParameter()
-
setReceiverParameter
public T setReceiverParameter(ReceiverParameter receiverParameter)
-
removeReceiverParameter
public CallableDeclaration removeReceiverParameter()
-
toCallableDeclaration
public Optional<CallableDeclaration> toCallableDeclaration()
- Overrides:
toCallableDeclaration
in classBodyDeclaration<T extends CallableDeclaration<?>>
-
-