Top Description Constructors Methods
org.apache.groovy.ast.tools

public Class MethodNodeUtils

extends Object
Class Inheritance
Imports
org.codehaus.groovy.ast.ClassHelper, .MethodNode, .Parameter, org.codehaus.groovy.ast.stmt.BlockStatement, .Statement

Utility class for working with MethodNodes

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static BlockStatement

Returns:

the found or created block statement
getCodeAsBlock
(final MethodNode
the method (or constructor) node
mNode
)

Gets the code for a method (or constructor) as a block.

public static String

Returns:

the property name without the get/set/is prefix if a property or null
getPropertyName
(final MethodNode
a MethodNode
mNode
)

For a method node potentially representing a property, returns the name of the property.

public static String

Returns:

the method node's descriptor
methodDescriptor
(final MethodNode
the method node
mNode
)

Return the method node's descriptor which includes its return type, name and parameter types without generics.

public static String

Returns:

the method node's abbreviated descriptor excluding the return type
methodDescriptorWithoutReturnType
(final MethodNode
the method node
mNode
)

Return the method node's descriptor including its name and parameter types without generics.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MethodNodeUtilsback to summary
private MethodNodeUtils()

Method Detail

getCodeAsBlockback to summary
public static BlockStatement getCodeAsBlock(final 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:MethodNode

the method (or constructor) node

Returns:BlockStatement

the found or created block statement

getPropertyNameback to summary
public static String getPropertyName(final MethodNode mNode)

For a method node potentially representing a property, returns the name of the property.

Parameters
mNode:MethodNode

a MethodNode

Returns:String

the property name without the get/set/is prefix if a property or null

methodDescriptorback to summary
public static String methodDescriptor(final MethodNode mNode)

Return the method node's descriptor which includes its return type, name and parameter types without generics.

Parameters
mNode:MethodNode

the method node

Returns:String

the method node's descriptor

methodDescriptorWithoutReturnTypeback to summary
public static String methodDescriptorWithoutReturnType(final MethodNode mNode)

Return the method node's descriptor including its name and parameter types without generics.

Parameters
mNode:MethodNode

the method node

Returns:String

the method node's abbreviated descriptor excluding the return type