Package groovy.lang

# Class MetaMethod

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

All Implemented Interfaces:
  `MetaMember`, `Cloneable`

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

public abstract class MetaMethod extends ParameterTypes implements MetaMember, 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 final MetaMethod[]`
  `EMPTY_ARRAY`
  Shared empty array of meta methods.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MetaMethod()`
  Constructor for a metamethod with an empty parameter list.
  `MetaMethod(Class[] pt)`
  Constructor with a list of parameter classes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkParameters(Class[] arguments)`
  Deprecated.
  `Object`
  `clone()`
  `Object`
  `doMethodInvoke(Object object, Object[] arguments)`
  Invokes the method this object represents.
  `protected static boolean`
  `equal(CachedClass[] a, Class[] b)`
  Compares cached parameter types against Java classes.
  `protected static boolean`
  `equal(CachedClass[] a, CachedClass[] b)`
  Compares two cached parameter type arrays.
  `abstract CachedClass`
  `getDeclaringClass()`
  Gets the class where this method is declared.
  `String`
  `getDescriptor()`
  Returns a descriptor of this method based on the return type and parameters of this method.
  `abstract int`
  `getModifiers()`
  Returns the modifiers of this method.
  `String`
  `getMopName()`
  Returns the method name used by Groovy's MOP bridge methods.
  `abstract String`
  `getName()`
  Returns the name of this method.
  `abstract Class`
  `getReturnType()`
  Returns the return type for this method.
  `String`
  `getSignature()`
  Returns the signature of this method.
  `abstract Object`
  `invoke(Object object, Object[] arguments)`
  Invokes this method.
  `boolean`
  `isAbstract()`
  Returns whether this method is abstract.
  `boolean`
  `isCacheable()`
  Returns whether this object is cacheable.
  `boolean`
  `isDefault()`
  Returns whether this method is interface-default.
  `boolean`
  `isMethod(MetaMethod method)`
  Returns true if this metamethod represents the same method as the argument.
  `final boolean`
  `isSame(MetaMethod method)`
  Determines if the given method has the same name, parameters, return type and modifiers but may be defined on another type.
  `final RuntimeException`
  `processDoMethodInvokeException(Exception e, Object object, Object[] arguments)`
  Called when an exception occurs while invoking this method.
  `String`
  `toString()`

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

  ### Methods inherited from interface groovy.lang.MetaMember

  `isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic`

- ## Field Details

  - ### EMPTY_ARRAY

    public static final MetaMethod[] EMPTY_ARRAY
    Shared empty array of meta methods.

- ## Constructor Details

  - ### MetaMethod

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

  - ### MetaMethod

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

- ## Method Details

  - ### getModifiers

    public abstract int getModifiers()
    Returns the modifiers of this method.
    Specified by:
      `getModifiers` in interface `MetaMember`
    Returns:
      modifiers as an int.

  - ### getName

    public abstract String getName()
    Returns the name of this method.
    Specified by:
      `getName` in interface `MetaMember`
    Returns:
      name of this method

  - ### getReturnType

    public abstract Class getReturnType()
    Returns 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

  - ### checkParameters

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

  - ### isMethod

    public boolean isMethod(MetaMethod method)
    Returns true if 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, Class[] b)
    Compares cached parameter types against Java classes.
    Parameters:
      `a` - cached parameter types
      `b` - Java parameter types
    Returns:
      `true` if the arrays describe the same parameter types

  - ### equal

    protected static boolean equal(CachedClass[] a, CachedClass[] b)
    Compares two cached parameter type arrays.
    Parameters:
      `a` - the first parameter type array
      `b` - the second parameter type array
    Returns:
      `true` if both arrays describe the same parameter types

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### clone

    public Object clone()
    Overrides:
      `clone` in class `Object`

  - ### isAbstract

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

  - ### isDefault

    public boolean isDefault()
    Returns whether this method is interface-default.
    Returns:
      true if this method is default

  - ### isSame

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

  - ### isCacheable

    public boolean isCacheable()
    Returns whether this object is cacheable.

  - ### getDescriptor

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

  - ### getSignature

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

  - ### getMopName

    public String getMopName()
    Returns the method name used by Groovy's MOP bridge methods.
    Returns:
      the synthetic MOP method name

  - ### invoke

    public abstract Object invoke(Object object, Object[] arguments)
    Invokes 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

  - ### doMethodInvoke

    public Object doMethodInvoke(Object object, Object[] arguments)
    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.
      `arguments` - Arguments for the method invocation.
    Returns:
      The return value of the invoked method.

  - ### processDoMethodInvokeException

    public final RuntimeException processDoMethodInvokeException(Exception e, Object object, Object[] arguments)
    Called when an exception occurs while invoking this method.