Package groovy.lang

# Class MetaMethod

java.lang.Object
org.codehaus.groovy.reflection.ParameterTypes
groovy.lang.MetaMethod

All Implemented Interfaces:
  `java.lang.Cloneable`

Direct Known Subclasses:
  `CachedMethod`, `CallSiteAwareMetaMethod`, `ClosureMetaMethod`, `ClosureStaticMetaMethod`, `GeneratedMetaMethod`, `MetaClassImpl.MetaConstructor`, `MixinInstanceMetaMethod`, `ReflectionMetaMethod`, `TransformMetaMethod`

    public abstract class MetaMethod
    extends ParameterTypes
    implements java.lang.Cloneable

Represents a Method on a Java object a little like `Method` except without using reflection to invoke the method

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `static MetaMethod[]` | `EMPTY_ARRAY` |

  ### Fields inherited from class org.codehaus.groovy.reflection.ParameterTypes

  `isVargsMethod, nativeParamTypes, parameterTypes`

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `MetaMethod()` | Constructor for a metamethod with an empty parameter list
  `MetaMethod​(java.lang.Class[] pt)` | Constructor wit a list of parameter classes

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `checkParameters​(java.lang.Class[] arguments)` | Checks that the given parameters are valid to call this method
  `java.lang.Object` | `clone()` |
  `java.lang.Object` | `doMethodInvoke​(java.lang.Object object, java.lang.Object[] argumentArray)` | Invokes the method this object represents.
  `protected static boolean` | `equal​(CachedClass[] a, java.lang.Class[] b)` |
  `protected static boolean` | `equal​(CachedClass[] a, CachedClass[] b)` |
  `abstract CachedClass` | `getDeclaringClass()` | Gets the class where this method is declared
  `java.lang.String` | `getDescriptor()` | Return a descriptor of this method based on the return type and parameters of this method.
  `abstract int` | `getModifiers()` | Returns the modifiers for this method
  `java.lang.String` | `getMopName()` |
  `abstract java.lang.String` | `getName()` | Returns the name of the method represented by this class
  `abstract java.lang.Class` | `getReturnType()` | Access the return type for this method
  `java.lang.String` | `getSignature()` | Returns the signature of this method
  `abstract java.lang.Object` | `invoke​(java.lang.Object object, java.lang.Object[] arguments)` | Invoke this method
  `boolean` | `isAbstract()` | Returns whether or not this method is abstract.
  `boolean` | `isCacheable()` | Returns whether this object is cacheable
  `boolean` | `isMethod​(MetaMethod method)` | Returns true if this this metamethod represents the same method as the argument.
  `boolean` | `isPrivate()` | Returns whether or not this method is private.
  `boolean` | `isProtected()` | Returns whether or not this method is protected.
  `boolean` | `isPublic()` | Returns whether or not this method is public.
  `boolean` | `isSame​(MetaMethod method)` |
  `boolean` | `isStatic()` | Returns whether or not this method is static.
  `java.lang.RuntimeException` | `processDoMethodInvokeException​(java.lang.Exception e, java.lang.Object object, java.lang.Object[] argumentArray)` | This method is called when an exception occurs while invoking this method.
  `java.lang.String` | `toString()` | Returns a string representation of this method

  ### Methods inherited from class org.codehaus.groovy.reflection.ParameterTypes

  `coerceArgumentsToClasses, correctArguments, getNativeParameterTypes, getParameterTypes, getPT, isValidExactMethod, isValidExactMethod, isValidMethod, isValidMethod, isVargsMethod, isVargsMethod, setParametersTypes`

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

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

- ## Field Details

  - ### EMPTY_ARRAY

    public static final MetaMethod[] EMPTY_ARRAY

- ## Constructor Details

  - ### MetaMethod

    public MetaMethod()
    Constructor for a metamethod with an empty parameter list

  - ### MetaMethod

    public MetaMethod​(java.lang.Class[] pt)
    Constructor wit a list of parameter classes
    Parameters:
      `pt` - A list of parameters types

- ## Method Details

  - ### getModifiers

    public abstract int getModifiers()
    Returns the modifiers for this method
    Returns:
      modifiers as an int.

  - ### getName

    public abstract java.lang.String getName()
    Returns the name of the method represented by this class
    Returns:
      name of this method

  - ### getReturnType

    public abstract java.lang.Class getReturnType()
    Access the return type for this method
    Returns:
      the return type of this method

  - ### getDeclaringClass

    public abstract CachedClass getDeclaringClass()
    Gets the class where this method is declared
    Returns:
      class of this method

  - ### invoke

    public abstract java.lang.Object invoke​(java.lang.Object object, java.lang.Object[] arguments)
    Invoke this method
    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

  - ### checkParameters

    public void checkParameters​(java.lang.Class[] arguments)
    Checks that the given parameters are valid to call this method
    Parameters:
      `arguments` - the arguments to check
    Throws:
      `java.lang.IllegalArgumentException` - if the parameters are not valid

  - ### isMethod

    public boolean isMethod​(MetaMethod method)
    Returns true if this this metamethod represents the same method as the argument.
    Parameters:
      `method` - A metaMethod instance
    Returns:
      true if method is for the same method as this method, false otherwise.

  - ### equal

    protected static boolean equal​(CachedClass[] a, java.lang.Class[] b)

  - ### equal

    protected static boolean equal​(CachedClass[] a, CachedClass[] b)

  - ### toString

    public java.lang.String toString()
    Returns a string representation of this method
    Overrides:
      `toString` in class `java.lang.Object`

  - ### clone

    public java.lang.Object clone()
    Overrides:
      `clone` in class `java.lang.Object`

  - ### isStatic

    public boolean isStatic()
    Returns whether or not this method is static.
    Returns:
      true if this method is static

  - ### isAbstract

    public boolean isAbstract()
    Returns whether or not this method is abstract.
    Returns:
      true if this method is abstract

  - ### isPrivate

    public final boolean isPrivate()
    Returns whether or not this method is private.
    Returns:
      true if this method is private

  - ### isProtected

    public final boolean isProtected()
    Returns whether or not this method is protected.
    Returns:
      true if this method is protected

  - ### isPublic

    public final boolean isPublic()
    Returns whether or not this method is public.
    Returns:
      true if this method is public

  - ### isSame

    public final boolean isSame​(MetaMethod method)
    Parameters:
      `method` - the method to compare against
    Returns:
      true if the given method has the same name, parameters, return type and modifiers but may be defined on another type

  - ### isCacheable

    public boolean isCacheable()
    Returns whether this object is cacheable

  - ### getDescriptor

    public java.lang.String getDescriptor()
    Return a descriptor of this method based on the return type and parameters of this method.

  - ### getSignature

    public java.lang.String getSignature()
    Returns the signature of this method
    Returns:
      The signature of this method

  - ### getMopName

    public java.lang.String getMopName()

  - ### processDoMethodInvokeException

    public final java.lang.RuntimeException processDoMethodInvokeException​(java.lang.Exception e, java.lang.Object object, java.lang.Object[] argumentArray)
    This method is called when an exception occurs while invoking this method.

  - ### doMethodInvoke

    public java.lang.Object doMethodInvoke​(java.lang.Object object, java.lang.Object[] argumentArray)
    Invokes the method this object represents. This method is not final but it should be overloaded very carefully and only by generated methods there is no guarantee that it will be called
    Parameters:
      `object` - The object the method is to be called at.
      `argumentArray` - Arguments for the method invocation.
    Returns:
      The return value of the invoked method.