Package: org.codehaus.groovy.runtime

## [Java] Class MethodClosure

- org.codehaus.groovy.runtime.MethodClosure

-     public class MethodClosure
      extends Closure

  Represents a method on an object using a closure, which can be invoked at any time.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static boolean` | `ALLOW_RESOLVE` |
    `static String` | `ANY_INSTANCE_METHOD_EXISTS` | Property name indicating whether an instance method exists for this method closure.
    `static String` | `NEW` | Method name constant for constructor invocations.

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class Closure` | `DELEGATE_FIRST, DELEGATE_ONLY, DONE, IDENTITY, OWNER_FIRST, OWNER_ONLY, TO_SELF, maximumNumberOfParameters, parameterTypes`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `MethodClosure(Object owner, String method)` Constructs a MethodClosure wrapping a method of the given owner object.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected Object` | `doCall(Object arguments)`
    `` | `public String` | `getMethod()`
    `` | `public Object` | `getOwner()`
    `` | `public Class<?>` | `getOwnerClass()` Returns the class of the owner object, unwrapping it if it's a Wrapper.
    `` | `public Object` | `getProperty(String property)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Closure` | `andThen, andThenSelf, andThenSelf, asWritable, call, call, call, checkForReferenceCycle, clone, compose, composeSelf, composeSelf, curry, curry, dehydrate, getDelegate, getDirective, getMaximumNumberOfParameters, getOwner, getParameterTypes, getProperty, getResolveStrategy, getThisObject, isCase, leftShift, leftShift, memoize, memoizeAtLeast, memoizeAtMost, memoizeBetween, ncurry, ncurry, rcurry, rcurry, rehydrate, rightShift, run, setDelegate, setDirective, setProperty, setResolveStrategy, throwRuntimeException, trampoline, trampoline`
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Field Detail

    - #### public static boolean ALLOW_RESOLVE

    - #### public static final String ANY_INSTANCE_METHOD_EXISTS

      Property name indicating whether an instance method exists for this method closure.

    - #### public static final String NEW

      Method name constant for constructor invocations.

  - ### Constructor Detail

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

    - #### protected Object doCall(Object arguments)

    - #### public String getMethod()

    - #### public Object getOwner()

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

    - #### public Object getProperty(String property)