Package: org.codehaus.groovy.ast

## [Java] Class MethodNode

- org.codehaus.groovy.ast.MethodNode

- All Implemented Interfaces and Traits:
    org.objectweb.asm.Opcodes

      public class MethodNode
      extends AnnotatedNode

  Represents a method declaration.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `SCRIPT_BODY_METHOD_KEY` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `Statement` | `code`
    `GenericsType[]` | `genericsTypes`
    `int` | `modifiers`
    `Parameter[]` | `parameters`
    `ClassNode` | `returnType`
    `boolean` | `syntheticPublic`
    `VariableScope` | `variableScope`

  - ### Constructor Summary

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

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Statement` | `getCode()`
    `` | `ClassNode[]` | `getExceptions()`
    `` | `Statement` | `getFirstStatement()`
    `` | `GenericsType[]` | `getGenericsTypes()`
    `` | `int` | `getModifiers()`
    `` | `String` | `getName()`
    `` | `Parameter[]` | `getParameters()`
    `` | `ClassNode` | `getReturnType()`
    `` | `String` | `getText()` Provides a nicely formatted string of the method definition.
    `` | `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.
    `` | `VariableScope` | `getVariableScope()`
    `` | `boolean` | `hasAnnotationDefault()`
    `` | `boolean` | `hasDefaultValue()`
    `` | `boolean` | `isAbstract()`
    `` | `boolean` | `isDefault()`
    `` | `boolean` | `isDynamicReturnType()`
    `` | `boolean` | `isFinal()`
    `` | `boolean` | `isPackageScope()`
    `` | `boolean` | `isPrivate()`
    `` | `boolean` | `isProtected()`
    `` | `boolean` | `isPublic()`
    `` | `boolean` | `isScriptBody()` @return true if this method is the run method from a script
    `` | `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 b)`
    `` | `void` | `setCode(Statement code)`
    `` | `void` | `setGenericsTypes(GenericsType[] genericsTypes)`
    `` | `void` | `setIsScriptBody()` Set the metadata flag for this method to indicate that 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()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AnnotatedNode` | `addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getNodeMetaData, getNodeMetaData, getText, putNodeMetaData, removeNodeMetaData, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setNodeMetaData, setSourcePosition, visit`

- - ### Field Detail

    - #### public static final String SCRIPT_BODY_METHOD_KEY

  - ### Property Detail

    - #### Statement code

    - #### GenericsType[] genericsTypes

    - #### int modifiers

    - #### Parameter[] parameters

    - #### ClassNode returnType

    - #### boolean syntheticPublic

    - #### VariableScope variableScope

  - ### Constructor Detail

    - #### protected MethodNode()

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

  - ### Method Detail

    - #### public Statement getCode()

    - #### public ClassNode[] getExceptions()

    - #### public Statement getFirstStatement()

    - #### public GenericsType[] getGenericsTypes()

    - #### public int getModifiers()

    - #### public String getName()

    - #### public Parameter[] getParameters()

    - #### public ClassNode getReturnType()

    - #### @Override public String getText()

      Provides a nicely formatted string of the method definition. For simplicity, generic types on some of the elements are not displayed.

      Returns:
        string form of node with some generic elements suppressed

    - #### 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.

      Returns:
        the type descriptor

    - #### public VariableScope getVariableScope()

    - #### public boolean hasAnnotationDefault()

    - #### public boolean hasDefaultValue()

    - #### public boolean isAbstract()

    - #### public boolean isDefault()

    - #### public boolean isDynamicReturnType()

    - #### public boolean isFinal()

    - #### public boolean isPackageScope()

    - #### public boolean isPrivate()

    - #### public boolean isProtected()

    - #### public boolean isPublic()

    - #### public boolean isScriptBody()

      Returns:
        true if this method is the run method from a script

    - #### public boolean isStatic()

    - #### public boolean isStaticConstructor()

    - #### 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

    - #### public boolean isVoidMethod()

    - #### public void setAnnotationDefault(boolean b)

    - #### public void setCode(Statement code)

    - #### public void setGenericsTypes(GenericsType[] genericsTypes)

    - #### public void setIsScriptBody()

      Set the metadata flag for this method to indicate that it is a script body implementation.

      See Also:
        ModuleNode.createStatementsClass

    - #### public void setModifiers(int modifiers)

    - #### public void setParameters(Parameter[] parameters)

    - #### public void setReturnType(ClassNode returnType)

    - #### public void setSyntheticPublic(boolean syntheticPublic)

    - #### public void setVariableScope(VariableScope variableScope)

    - #### public String toString()