APIdia Launch Partner
Top Description Methods
com.sun.source.tree

public Interface MethodTree

extends Tree
Known Direct Implementers
com.sun.tools.javac.tree.JCTree.JCMethodDecl
Imports
java.util.List, javax.lang.model.element.Name

A tree node for a method or annotation type element declaration. For example:
  modifiers typeParameters type name
     ( parameters )
     body

  modifiers type name () default defaultValue
Authors
Peter von der Ahé, Jonathan Gibbons
Since
1.6
Java Language Specification
8.4 Method Declarations, 8.6 Instance Initializers, 8.7 Static Initializers, 9.4 Method Declarations, 9.6.1 Annotation Interface Elements

Method Summary

Modifier and TypeMethod and Description
public BlockTree

Returns:

the method body
getBody
()

Returns the method body, or null if this is an abstract or native method.

public Tree

Returns:

the default value
getDefaultValue
()

Returns the default value, if this is an element within an annotation type declaration.

public ModifiersTree

Returns:

the modifiers
getModifiers
()

Returns the modifiers, including any annotations for the method being declared.

public Name

Returns:

the name
getName
()

Returns the name of the method being declared.

public List<? extends VariableTree>

Returns:

the parameters
getParameters
()

Returns the parameters of the method being declared.

public VariableTree

Returns:

an explicit receiver parameter ("this" parameter)
getReceiverParameter
()

Return an explicit receiver parameter ("this" parameter), or null if none.

public Tree

Returns:

the return type
getReturnType
()

Returns the return type of the method being declared.

public List<? extends ExpressionTree>

Returns:

the exceptions
getThrows
()

Returns the exceptions listed as being thrown by this method.

public List<? extends TypeParameterTree>

Returns:

the type parameters
getTypeParameters
()

Returns the type parameters of the method being declared.

Inherited from com.sun.source.tree.Tree:
acceptgetKind

Method Detail

getBodyback to summary
public BlockTree getBody()

Returns the method body, or null if this is an abstract or native method.

Returns:BlockTree

the method body

getDefaultValueback to summary
public Tree getDefaultValue()

Returns the default value, if this is an element within an annotation type declaration. Returns null otherwise.

Returns:Tree

the default value

getModifiersback to summary
public ModifiersTree getModifiers()

Returns the modifiers, including any annotations for the method being declared.

Returns:ModifiersTree

the modifiers

getNameback to summary
public Name getName()

Returns the name of the method being declared.

Returns:Name

the name

getParametersback to summary
public List<? extends VariableTree> getParameters()

Returns the parameters of the method being declared.

Returns:List<? extends VariableTree>

the parameters

getReceiverParameterback to summary
public VariableTree getReceiverParameter()

Return an explicit receiver parameter ("this" parameter), or null if none.

Returns:VariableTree

an explicit receiver parameter ("this" parameter)

Since
1.8
getReturnTypeback to summary
public Tree getReturnType()

Returns the return type of the method being declared. Returns null for a constructor.

Returns:Tree

the return type

getThrowsback to summary
public List<? extends ExpressionTree> getThrows()

Returns the exceptions listed as being thrown by this method.

Returns:List<? extends ExpressionTree>

the exceptions

getTypeParametersback to summary
public List<? extends TypeParameterTree> getTypeParameters()

Returns the type parameters of the method being declared.

Returns:List<? extends TypeParameterTree>

the type parameters