Class ClosureMetaMethod

java.lang.Object
org.codehaus.groovy.reflection.ParameterTypes
groovy.lang.MetaMethod
org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod
All Implemented Interfaces:
ClosureInvokingMethod, java.lang.Cloneable

public class ClosureMetaMethod
extends MetaMethod
implements ClosureInvokingMethod
A MetaMethod that accepts a closure in the constructor which is invoked when the MetaMethod is called. The delegate of the closure is set to the instance that the MetaMethod is invoked on when called.
Since:
1.5
  • Constructor Details

    • ClosureMetaMethod

      public ClosureMetaMethod​(java.lang.String name, Closure c, CachedMethod doCall)
    • ClosureMetaMethod

      public ClosureMetaMethod​(java.lang.String name, java.lang.Class declaringClass, Closure c, CachedMethod doCall)
  • Method Details

    • getModifiers

      public int getModifiers()
      Description copied from class: MetaMethod
      Returns the modifiers for this method
      Specified by:
      getModifiers in class MetaMethod
      Returns:
      modifiers as an int.
    • getName

      public java.lang.String getName()
      Description copied from class: MetaMethod
      Returns the name of the method represented by this class
      Specified by:
      getName in interface ClosureInvokingMethod
      Specified by:
      getName in class MetaMethod
      Returns:
      name of this method
    • getReturnType

      public java.lang.Class getReturnType()
      Description copied from class: MetaMethod
      Access the return type for this method
      Specified by:
      getReturnType in class MetaMethod
      Returns:
      the return type of this method
    • getDeclaringClass

      public CachedClass getDeclaringClass()
      Description copied from class: MetaMethod
      Gets the class where this method is declared
      Specified by:
      getDeclaringClass in class MetaMethod
      Returns:
      class of this method
    • invoke

      public java.lang.Object invoke​(java.lang.Object object, java.lang.Object[] arguments)
      Description copied from class: MetaMethod
      Invoke this method
      Specified by:
      invoke in class MetaMethod
      Parameters:
      object - The object this method should be invoked on
      arguments - The arguments for the method if applicable
      Returns:
      The return value of the invocation
    • getClosure

      public Closure getClosure()
      Retrieves the closure that is invoked by this MetaMethod
      Specified by:
      getClosure in interface ClosureInvokingMethod
      Returns:
      The closure
    • createMethodList

      public static java.util.List<MetaMethod> createMethodList​(java.lang.String name, java.lang.Class declaringClass, Closure closure)
    • getDoCall

      public CachedMethod getDoCall()
    • copy

      public static ClosureMetaMethod copy​(ClosureMetaMethod closureMethod)