Package org.codehaus.groovy.ast

# Class MethodNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.MethodNode

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`

Direct Known Subclasses:
  `ConstructorNode`, `ExtensionMethodNode`

public class MethodNode extends AnnotatedNode
Represents a method declaration.

- ## Field Summary

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `MethodNode()`
  ``
  `MethodNode(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Statement`
  `getCode()`
  `ClassNode[]`
  `getExceptions()`
  `Statement`
  `getFirstStatement()`
  `GenericsType[]`
  `getGenericsTypes()`
  `int`
  `getModifiers()`
  `String`
  `getName()`
  `Parameter[]`
  `getParameters()`
  `ClassNode`
  `getReturnType()`
  `String`
  `getText()`
  `String`
  `getTypeDescriptor()`
  The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form.
  `String`
  `getTypeDescriptor(boolean pretty)`
  Deprecated.
  use `MethodNodeUtils.methodDescriptor(MethodNode, boolean)`
  `VariableScope`
  `getVariableScope()`
  `boolean`
  `hasAnnotationDefault()`
  `boolean`
  `hasDefaultValue()`
  `boolean`
  `isAbstract()`
  `boolean`
  `isConstructor()`
  `boolean`
  `isDefault()`
  `boolean`
  `isDynamicReturnType()`
  `boolean`
  `isFinal()`
  `boolean`
  `isPackageScope()`
  `boolean`
  `isPrivate()`
  `boolean`
  `isProtected()`
  `boolean`
  `isPublic()`
  `boolean`
  `isScriptBody()`
  `boolean`
  `isStatic()`
  `boolean`
  `isStaticConstructor()`
  `boolean`
  `isSyntheticPublic()`
  Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code.
  `boolean`
  `isVoidMethod()`
  `void`
  `setAnnotationDefault(boolean hasDefaultValue)`
  `void`
  `setCode(Statement code)`
  `void`
  `setGenericsTypes(GenericsType[] genericsTypes)`
  `void`
  `setIsScriptBody()`
  Sets the flag for this method to indicate it is a script body implementation.
  `void`
  `setModifiers(int modifiers)`
  `void`
  `setParameters(Parameter[] parameters)`
  `void`
  `setReturnType(ClassNode returnType)`
  `void`
  `setSyntheticPublic(boolean syntheticPublic)`
  `void`
  `setVariableScope(VariableScope variableScope)`
  `String`
  `toString()`

  ### Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode

  `addAnnotation, addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### MethodNode

    protected MethodNode()

  - ### MethodNode

    public MethodNode(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)

- ## Method Details

  - ### getTypeDescriptor

    public String getTypeDescriptor()
    The type descriptor for a method node is a string containing the name of the method, its return type, and its parameter types in a canonical form. For simplicity, we use the format of a Java declaration without parameter names or generics.

  - ### getTypeDescriptor

    @Deprecated public String getTypeDescriptor(boolean pretty)
    Deprecated.
    use `MethodNodeUtils.methodDescriptor(MethodNode, boolean)`

  - ### getCode

    public Statement getCode()

  - ### setCode

    public void setCode(Statement code)

  - ### getModifiers

    public int getModifiers()

  - ### setModifiers

    public void setModifiers(int modifiers)

  - ### getName

    public String getName()

  - ### getParameters

    public Parameter[] getParameters()

  - ### setParameters

    public void setParameters(Parameter[] parameters)

  - ### hasDefaultValue

    public boolean hasDefaultValue()
    Returns:
      `true` if any parameter has a default value

  - ### getReturnType

    public ClassNode getReturnType()

  - ### setReturnType

    public void setReturnType(ClassNode returnType)

  - ### isDynamicReturnType

    public boolean isDynamicReturnType()

  - ### isVoidMethod

    public boolean isVoidMethod()

  - ### getVariableScope

    public VariableScope getVariableScope()

  - ### setVariableScope

    public void setVariableScope(VariableScope variableScope)

  - ### isAbstract

    public boolean isAbstract()

  - ### isDefault

    public boolean isDefault()

  - ### isFinal

    public boolean isFinal()

  - ### isStatic

    public boolean isStatic()

  - ### isPublic

    public boolean isPublic()

  - ### isPrivate

    public boolean isPrivate()

  - ### isProtected

    public boolean isProtected()

  - ### isPackageScope

    public boolean isPackageScope()

  - ### getExceptions

    public ClassNode[] getExceptions()

  - ### getFirstStatement

    public Statement getFirstStatement()

  - ### getGenericsTypes

    public GenericsType[] getGenericsTypes()

  - ### setGenericsTypes

    public void setGenericsTypes(GenericsType[] genericsTypes)

  - ### hasAnnotationDefault

    public boolean hasAnnotationDefault()
    Returns:
      `true` if annotation method has a default value

  - ### setAnnotationDefault

    public void setAnnotationDefault(boolean hasDefaultValue)

  - ### isScriptBody

    public boolean isScriptBody()
    Returns:
      `true` if this method is the run method from a script

  - ### setIsScriptBody

    public void setIsScriptBody()
    Sets the flag for this method to indicate it is a script body implementation.
    See Also:
      - `ModuleNode.createStatementsClass()`

  - ### isStaticConstructor

    public boolean isStaticConstructor()

  - ### isConstructor

    public boolean isConstructor()

  - ### isSyntheticPublic

    public boolean isSyntheticPublic()
    Indicates that this method has been "promoted" to public by Groovy when in fact there was no public modifier explicitly in the source code. I.e. it remembers that it has applied Groovy's "public methods by default" rule. This property is typically only of interest to AST transform writers.
    Returns:
      `true` if this class is public but had no explicit public modifier

  - ### setSyntheticPublic

    public void setSyntheticPublic(boolean syntheticPublic)

  - ### getText

    public String getText()
    Overrides:
      `getText` in class `ASTNode`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`