Top Description Inners Fields Constructors Methods
com.github.javaparser.ast.body

public abstract Class CallableDeclaration<T extends CallableDeclaration<?>>

extends BodyDeclaration<T extends CallableDeclaration<?>>
implements NodeWithAccessModifiers<T extends CallableDeclaration<?>>, NodeWithDeclaration, NodeWithSimpleName<T extends CallableDeclaration<?>>, NodeWithParameters<T extends CallableDeclaration<?>>, NodeWithThrownExceptions<T extends CallableDeclaration<?>>, NodeWithTypeParameters<T extends CallableDeclaration<?>>, NodeWithJavadoc<T extends CallableDeclaration<?>>, NodeWithAbstractModifier<T extends CallableDeclaration<?>>, NodeWithStaticModifier<T extends CallableDeclaration<?>>, NodeWithFinalModifier<T extends CallableDeclaration<?>>, NodeWithStrictfpModifier<T extends CallableDeclaration<?>>
Class Inheritance
All Implemented Interfaces
com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier, com.github.javaparser.ast.nodeTypes.NodeWithModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithFinalModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAbstractModifier, com.github.javaparser.ast.nodeTypes.NodeWithJavadoc, com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters, com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions, com.github.javaparser.ast.nodeTypes.NodeWithParameters, com.github.javaparser.ast.nodeTypes.NodeWithSimpleName, com.github.javaparser.ast.nodeTypes.NodeWithDeclaration, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithAccessModifiers, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier, com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
Known Direct Subclasses
com.github.javaparser.ast.body.ConstructorDeclaration, com.github.javaparser.ast.body.MethodDeclaration
Imports
com.github.javaparser.TokenRange, com.github.javaparser.ast.AllFieldsConstructor, .Modifier, .Node, .NodeList, .Generated, com.github.javaparser.ast.expr.AnnotationExpr, .SimpleName, com.github.javaparser.ast.nodeTypes.*, com.github.javaparser.ast.nodeTypes.modifiers.*, com.github.javaparser.ast.observer.ObservableProperty, com.github.javaparser.ast.type.ArrayType, .ReferenceType, .Type, .TypeParameter, com.github.javaparser.ast.visitor.CloneVisitor, com.github.javaparser.metamodel.CallableDeclarationMetaModel, .JavaParserMetaModel, .OptionalProperty, java.util.List, .Optional, java.util.function.Consumer

Represents a declaration which is callable eg. a method or a constructor.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CallableDeclaration.Signature

A method or constructor signature.

Field Summary

Modifier and TypeField and Description
private NodeList<Modifier>
private SimpleName
private NodeList<Parameter>
private ReceiverParameter
private NodeList<ReferenceType>
private NodeList<TypeParameter>

Constructor Summary

AccessConstructor and Description
pack-priv
CallableDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, ReceiverParameter receiverParameter)

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 Summary

Modifier and TypeMethod and Description
protected String
appendThrowsIfRequested(boolean includingThrows)

public CallableDeclaration<T extends CallableDeclaration<?>>
public CallableDeclaration<?>
clone()

Overrides com.github.javaparser.ast.body.BodyDeclaration.clone.

Creates and returns a copy of this object.
public CallableDeclarationMetaModel
public NodeList<Modifier>

Returns:

modifiers
getModifiers
()

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.getModifiers.

Return the modifiers of this member declaration.
public SimpleName
public NodeList<Parameter>
public Optional<ReceiverParameter>
public CallableDeclaration.Signature
public NodeList<ReferenceType>
public NodeList<TypeParameter>
private Type
public void
public boolean
public boolean
public CallableDeclaration<T extends CallableDeclaration<?>>
public boolean
public T
public T
public T
public T
setReceiverParameter(final ReceiverParameter receiverParameter)

public T
public T
private Type
private Type
public Optional<CallableDeclaration<T extends CallableDeclaration<?>>>
Inherited from com.github.javaparser.ast.body.BodyDeclaration:
asAnnotationDeclarationasAnnotationMemberDeclarationasClassOrInterfaceDeclarationasConstructorDeclarationasEnumConstantDeclarationasEnumDeclarationasFieldDeclarationasInitializerDeclarationasMethodDeclarationasTypeDeclarationgetAnnotationsifAnnotationDeclarationifAnnotationMemberDeclarationifClassOrInterfaceDeclarationifConstructorDeclarationifEnumConstantDeclarationifEnumDeclarationifFieldDeclarationifInitializerDeclarationifMethodDeclarationifTypeDeclarationisAnnotationDeclarationisAnnotationMemberDeclarationisClassOrInterfaceDeclarationisConstructorDeclarationisEnumConstantDeclarationisEnumDeclarationisFieldDeclarationisInitializerDeclarationisMethodDeclarationisTypeDeclarationsetAnnotationstoAnnotationDeclarationtoAnnotationMemberDeclarationtoClassOrInterfaceDeclarationtoConstructorDeclarationtoEnumConstantDeclarationtoEnumDeclarationtoFieldDeclarationtoInitializerDeclarationtoMethodDeclarationtoTypeDeclaration

Field Detail

modifiersback to summary
private NodeList<Modifier> modifiers
nameback to summary
private SimpleName name
parametersback to summary
private NodeList<Parameter> parameters
receiverParameterback to summary
private ReceiverParameter receiverParameter
Annotations
@OptionalProperty
thrownExceptionsback to summary
private NodeList<ReferenceType> thrownExceptions
typeParametersback to summary
private NodeList<TypeParameter> typeParameters

Constructor Detail

CallableDeclarationback to summary
pack-priv CallableDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, NodeList<TypeParameter> typeParameters, SimpleName name, NodeList<Parameter> parameters, NodeList<ReferenceType> thrownExceptions, ReceiverParameter receiverParameter)
Annotations
@AllFieldsConstructor
CallableDeclarationback to summary
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.

Annotations
@Generated:com.github.javaparser.generator.core.node.MainConstructorGenerator

Method Detail

appendThrowsIfRequestedback to summary
protected String appendThrowsIfRequested(boolean includingThrows)
asCallableDeclarationback to summary
public CallableDeclaration<T extends CallableDeclaration<?>> asCallableDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.asCallableDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
cloneback to summary
public CallableDeclaration<?> clone()

Overrides com.github.javaparser.ast.body.BodyDeclaration.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:CallableDeclaration<?>

a clone of this instance.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.CloneGenerator
getMetaModelback to summary
public CallableDeclarationMetaModel getMetaModel()

Overrides com.github.javaparser.ast.body.BodyDeclaration.getMetaModel.

Returns:CallableDeclarationMetaModel

Doc from com.github.javaparser.ast.Node.getMetaModel.

get JavaParser specific node introspection information.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.GetMetaModelGenerator
getModifiersback to summary
public NodeList<Modifier> getModifiers()

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.getModifiers.

Return the modifiers of this member declaration.

Returns:NodeList<Modifier>

modifiers

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
See Also
Modifier
getNameback to summary
public SimpleName getName()

Implements com.github.javaparser.ast.nodeTypes.NodeWithSimpleName.getName.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getParametersback to summary
public NodeList<Parameter> getParameters()

Implements com.github.javaparser.ast.nodeTypes.NodeWithParameters.getParameters.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getReceiverParameterback to summary
public Optional<ReceiverParameter> getReceiverParameter()
Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getSignatureback to summary
public CallableDeclaration.Signature getSignature()
getThrownExceptionsback to summary
public NodeList<ReferenceType> getThrownExceptions()

Implements com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions.getThrownExceptions.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getTypeParametersback to summary
public NodeList<TypeParameter> getTypeParameters()

Implements com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters.getTypeParameters.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
getTypeWithVarargsAsArrayback to summary
private Type getTypeWithVarargsAsArray(Parameter p)
ifCallableDeclarationback to summary
public void ifCallableDeclaration(Consumer<CallableDeclaration<T extends CallableDeclaration<?>>> action)

Overrides com.github.javaparser.ast.body.BodyDeclaration.ifCallableDeclaration.

Annotations
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
isCallableDeclarationback to summary
public boolean isCallableDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.isCallableDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
removeback to summary
public boolean remove(Node node)

Overrides com.github.javaparser.ast.body.BodyDeclaration.remove.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.RemoveMethodGenerator
removeReceiverParameterback to summary
public CallableDeclaration<T extends CallableDeclaration<?>> removeReceiverParameter()
Annotations
@Generated:com.github.javaparser.generator.core.node.RemoveMethodGenerator
replaceback to summary
public boolean replace(Node node, Node replacementNode)

Overrides com.github.javaparser.ast.body.BodyDeclaration.replace.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.ReplaceMethodGenerator
setModifiersback to summary
public T setModifiers(final NodeList<Modifier> modifiers)

Implements com.github.javaparser.ast.nodeTypes.NodeWithModifiers.setModifiers.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setNameback to summary
public T setName(final SimpleName name)

Implements com.github.javaparser.ast.nodeTypes.NodeWithSimpleName.setName.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setParametersback to summary
public T setParameters(final NodeList<Parameter> parameters)

Implements com.github.javaparser.ast.nodeTypes.NodeWithParameters.setParameters.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setReceiverParameterback to summary
public T setReceiverParameter(final ReceiverParameter receiverParameter)
Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setThrownExceptionsback to summary
public T setThrownExceptions(final NodeList<ReferenceType> thrownExceptions)

Implements com.github.javaparser.ast.nodeTypes.NodeWithThrownExceptions.setThrownExceptions.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
setTypeParametersback to summary
public T setTypeParameters(final NodeList<TypeParameter> typeParameters)

Implements com.github.javaparser.ast.nodeTypes.NodeWithTypeParameters.setTypeParameters.

Annotations
@Generated:com.github.javaparser.generator.core.node.PropertyGenerator
@SuppressWarnings:unchecked
stripAnnotationsback to summary
private Type stripAnnotations(Type type)
stripGenericsback to summary
private Type stripGenerics(Type type)
toCallableDeclarationback to summary
public Optional<CallableDeclaration<T extends CallableDeclaration<?>>> toCallableDeclaration()

Overrides com.github.javaparser.ast.body.BodyDeclaration.toCallableDeclaration.

Annotations
@Override
@Generated:com.github.javaparser.generator.core.node.TypeCastingGenerator
com.github.javaparser.ast.body back to summary

public Class CallableDeclaration.Signature

extends Object
Class Inheritance

A method or constructor signature.

Note that since JavaParser has no real knowledge of types - only the text found in the source file - using this will fail in some cases. (java.util.String != String for example, and generics are not taken into account.)

Field Summary

Modifier and TypeField and Description
private final String
private final List<Type>

Constructor Summary

AccessConstructor and Description
private
Signature(String name, List<Type> parameterTypes)

Method Summary

Modifier and TypeMethod and Description
public String
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String
public List<Type>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name
parameterTypesback to summary
private final List<Type> parameterTypes

Constructor Detail

Signatureback to summary
private Signature(String name, List<Type> parameterTypes)

Method Detail

asStringback to summary
public String asString()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getNameback to summary
public String getName()
getParameterTypesback to summary
public List<Type> getParameterTypes()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override