MethodNodeUtils (Groovy 5.0.7)
Description: declaration: package: org.apache.groovy.ast.tools, class: MethodNodeUtils

Package org.apache.groovy.ast.tools

# Class MethodNodeUtils

java.lang.Object
org.apache.groovy.ast.tools.MethodNodeUtils

public class MethodNodeUtils extends Object
Utility class for working with MethodNodes

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static BlockStatement`
  `getCodeAsBlock(MethodNode mNode)`
  Gets the code for a method (or constructor) as a block.
  `static String`
  `getPropertyName(MethodNode mNode)`
  For a method node potentially representing a property, returns the name of the property.
  `static boolean`
  `isGetterCandidate(MethodNode mNode)`
  Determines if given method is a getter candidate.
  `static String`
  `methodDescriptor(MethodNode mNode)`
  Return the method node's descriptor which includes its return type, name and parameter types without generics.
  `static String`
  `methodDescriptor(MethodNode mNode, boolean pretty)`
  Return the method node's descriptor which includes its return type, name and parameter types without generics.
  `static String`
  `methodDescriptorWithoutReturnType(MethodNode mNode)`
  Return the method node's descriptor including its name and parameter types without generics.
  `static List<MethodNode>`
  `withDefaultArgumentMethods(List<? extends MethodNode> methods)`
  Returns new list that includes methods that will be generated for default argument expressions.

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

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

- ## Method Details

  - ### methodDescriptorWithoutReturnType

    public static String methodDescriptorWithoutReturnType(MethodNode mNode)
    Return the method node's descriptor including its name and parameter types without generics.
    Parameters:
      `mNode` - the method node
    Returns:
      the method node's abbreviated descriptor excluding the return type

  - ### methodDescriptor

    public static String methodDescriptor(MethodNode mNode)
    Return the method node's descriptor which includes its return type, name and parameter types without generics.
    Parameters:
      `mNode` - the method node
    Returns:
      the method node's descriptor

  - ### methodDescriptor

    public static String methodDescriptor(MethodNode mNode, boolean pretty)
    Return the method node's descriptor which includes its return type, name and parameter types without generics.
    Parameters:
      `mNode` - the method node
      `pretty` - whether to quote a name with spaces
    Returns:
      the method node's descriptor

  - ### getPropertyName

    public static String getPropertyName(MethodNode mNode)
    For a method node potentially representing a property, returns the name of the property.
    Parameters:
      `mNode` - a MethodNode
    Returns:
      the property name without the get/set/is prefix if a property or null

  - ### getCodeAsBlock

    public static BlockStatement getCodeAsBlock(MethodNode mNode)
    Gets the code for a method (or constructor) as a block. If no code is found, an empty block will be returned. If a single non-block statement is found, a block containing that statement will be returned. Otherwise the existing block statement will be returned. The original `node` is not modified.
    Parameters:
      `mNode` - the method (or constructor) node
    Returns:
      the found or created block statement

  - ### isGetterCandidate

    public static boolean isGetterCandidate(MethodNode mNode)
    Determines if given method is a getter candidate.
    Since:
      4.0.0

  - ### withDefaultArgumentMethods

    public static List<MethodNode> withDefaultArgumentMethods(List<? extends MethodNode> methods)
    Returns new list that includes methods that will be generated for default argument expressions.
    Since:
      5.0.0