Class MethodClosure

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Closure
org.codehaus.groovy.runtime.MethodClosure
All Implemented Interfaces:
GroovyCallable, GroovyObject, Serializable, Cloneable, Runnable, Callable

public class MethodClosure extends Closure
Represents a method on an object using a closure, which can be invoked at any time.
See Also:
  • Field Details

    • ALLOW_RESOLVE

      public static boolean ALLOW_RESOLVE
      Enables flexible object serialization behavior for MethodClosure instances.
    • ANY_INSTANCE_METHOD_EXISTS

      public static final String ANY_INSTANCE_METHOD_EXISTS
      Property name indicating whether an instance method exists for this method closure.
      See Also:
    • NEW

      public static final String NEW
      Method name constant for constructor invocations.
      See Also:
  • Constructor Details

    • MethodClosure

      public MethodClosure(Object owner, String method)
      Constructs a MethodClosure wrapping a method of the given owner object.
      Parameters:
      owner - the object on which the method is invoked, or a Class for static methods
      method - the name of the method to wrap, or "new" for constructor invocations
  • Method Details

    • getMethod

      public String getMethod()
    • getOwner

      public Object getOwner()
      Overrides:
      getOwner in class Closure
      Returns:
      the owner Object to which method calls will go which is typically the outer class when the closure is constructed
    • getOwnerClass

      public Class<?> getOwnerClass()
      Returns the class of the owner object, unwrapping it if it's a Wrapper. If the owner is a Class, returns that Class; otherwise, returns the class of the owner.
      Returns:
      the class of the owner object
      Since:
      5.0.0
    • getProperty

      public Object getProperty(String property)
      Description copied from class: Closure
      Retrieves a property value.
      Specified by:
      getProperty in interface GroovyObject
      Overrides:
      getProperty in class Closure
      Parameters:
      property - the name of the property of interest
      Returns:
      the given property
    • doCall

      protected Object doCall(Object arguments)