Top Description Fields Constructors Methods
groovy.lang

public abstract Class MetaMethod

extends ParameterTypes
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
org.codehaus.groovy.reflection.CachedMethod, org.codehaus.groovy.reflection.GeneratedMetaMethod, org.codehaus.groovy.runtime.callsite.CallSiteAwareMetaMethod, org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod, org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.AnonymousMetaMethod, org.codehaus.groovy.runtime.metaclass.ClosureStaticMetaMethod, org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod, org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod, org.codehaus.groovy.runtime.metaclass.ThreadManagedMetaBeanProperty.ThreadBoundGetter, org.codehaus.groovy.runtime.metaclass.ThreadManagedMetaBeanProperty.ThreadBoundSetter, org.codehaus.groovy.runtime.metaclass.TransformMetaMethod, groovy.lang.MetaClassImpl.MetaConstructor, groovy.lang.MetaClassImpl.DummyMetaMethod
Imports
org.codehaus.groovy.classgen.asm.BytecodeHelper, org.codehaus.groovy.reflection.CachedClass, .ParameterTypes, org.codehaus.groovy.runtime.InvokerHelper, .MetaClassHelper, java.lang.reflect.Modifier

Represents a Method on a Java object a little like java.lang.reflect.Method except without using reflection to invoke the method

Field Summary

Modifier and TypeField and Description
public static final MetaMethod[]
private String
private String
Inherited from org.codehaus.groovy.reflection.ParameterTypes:
isVargsMethodnativeParamTypesparameterTypes

Constructor Summary

AccessConstructor and Description
public
MetaMethod()

Constructor for a metamethod with an empty parameter list

public
MetaMethod(Class<T>[]
A list of parameters types
pt
)

Constructor wit a list of parameter classes

Method Summary

Modifier and TypeMethod and Description
public void
checkParameters(Class<T>[]
the arguments to check
arguments
)

Checks that the given parameters are valid to call this method

public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
private static boolean

Returns:

true if the modifiers are compatible
compatibleModifiers
(int modifiersA, int modifiersB)

Checks the compatibility between two modifier masks.

public Object

Returns:

The return value of the invoked method.
doMethodInvoke
(Object
The object the method is to be called at.
object
,
Object[]
Arguments for the method invocation.
argumentArray
)

Invokes the method this object represents.

protected static boolean
equal(CachedClass[] a, Class<T>[] b)

protected static boolean
public abstract CachedClass

Returns:

class of this method
getDeclaringClass
()

Gets the class where this method is declared

public String
getDescriptor()

Return a descriptor of this method based on the return type and parameters of this method.

public abstract int

Returns:

modifiers as an int.
getModifiers
()

Returns the modifiers for this method

public String
public abstract String

Returns:

name of this method
getName
()

Returns the name of the method represented by this class

public abstract Class<T>

Returns:

the return type of this method
getReturnType
()

Access the return type for this method

public synchronized String

Returns:

The signature of this method
getSignature
()

Returns the signature of this method

public abstract Object

Returns:

The return value of the invocation
invoke
(Object
The object this method should be invoked on
object
,
Object[]
The arguments for the method if applicable
arguments
)

Invoke this method

public boolean

Returns:

true if this method is abstract
isAbstract
()

Returns whether or not this method is abstract.

public boolean
isCacheable()

Returns whether this object is cacheable

public boolean

Returns:

true if method is for the same method as this method, false otherwise.
isMethod
(MetaMethod
A metaMethod instance
method
)

Returns true if this this metamethod represents the same method as the argument.

public final boolean

Returns:

true if this method is private
isPrivate
()

Returns whether or not this method is private.

public final boolean

Returns:

true if this method is protected
isProtected
()

Returns whether or not this method is protected.

public final boolean

Returns:

true if this method is public
isPublic
()

Returns whether or not this method is public.

public final boolean

Returns:

true if the given method has the same name, parameters, return type and modifiers but may be defined on another type
isSame
(MetaMethod
the method to compare against
method
)

public boolean

Returns:

true if this method is static
isStatic
()

Returns whether or not this method is static.

public final RuntimeException
processDoMethodInvokeException(Exception e, Object object, Object[] argumentArray)

This method is called when an exception occurs while invoking this method.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of this method
Inherited from org.codehaus.groovy.reflection.ParameterTypes:
coerceArgumentsToClassescorrectArgumentsgetNativeParameterTypesgetParameterTypesgetPTisValidExactMethodisValidExactMethodisValidMethodisValidMethodisVargsMethodisVargsMethodsetParametersTypes

Field Detail

EMPTY_ARRAYback to summary
public static final MetaMethod[] EMPTY_ARRAY
mopNameback to summary
private String mopName
signatureback to summary
private String signature

Constructor Detail

MetaMethodback to summary
public MetaMethod()

Constructor for a metamethod with an empty parameter list

MetaMethodback to summary
public MetaMethod(Class<T>[] pt)

Constructor wit a list of parameter classes

Parameters
pt:Class<T>[]

A list of parameters types

Method Detail

checkParametersback to summary
public void checkParameters(Class<T>[] arguments)

Checks that the given parameters are valid to call this method

Parameters
arguments:Class<T>[]

the arguments to check

Exceptions
IllegalArgumentException:
if the parameters are not valid
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

compatibleModifiersback to summary
private static boolean compatibleModifiers(int modifiersA, int modifiersB)

Checks the compatibility between two modifier masks. Checks that they are equal with regards to access and static modifier.

Returns:boolean

true if the modifiers are compatible

doMethodInvokeback to summary
public Object doMethodInvoke(Object object, 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:Object

The object the method is to be called at.

argumentArray:Object[]

Arguments for the method invocation.

Returns:Object

The return value of the invoked method.

equalback to summary
protected static boolean equal(CachedClass[] a, Class<T>[] b)
equalback to summary
protected static boolean equal(CachedClass[] a, CachedClass[] b)
getDeclaringClassback to summary
public abstract CachedClass getDeclaringClass()

Gets the class where this method is declared

Returns:CachedClass

class of this method

getDescriptorback to summary
public String getDescriptor()

Return a descriptor of this method based on the return type and parameters of this method.

getModifiersback to summary
public abstract int getModifiers()

Returns the modifiers for this method

Returns:int

modifiers as an int.

getMopNameback to summary
public String getMopName()
getNameback to summary
public abstract String getName()

Returns the name of the method represented by this class

Returns:String

name of this method

getReturnTypeback to summary
public abstract Class<T> getReturnType()

Access the return type for this method

Returns:Class<T>

the return type of this method

getSignatureback to summary
public synchronized String getSignature()

Returns the signature of this method

Returns:String

The signature of this method

invokeback to summary
public abstract Object invoke(Object object, Object[] arguments)

Invoke this method

Parameters
object:Object

The object this method should be invoked on

arguments:Object[]

The arguments for the method if applicable

Returns:Object

The return value of the invocation

isAbstractback to summary
public boolean isAbstract()

Returns whether or not this method is abstract.

Returns:boolean

true if this method is abstract

isCacheableback to summary
public boolean isCacheable()

Returns whether this object is cacheable

isMethodback to summary
public boolean isMethod(MetaMethod method)

Returns true if this this metamethod represents the same method as the argument.

Parameters
method:MetaMethod

A metaMethod instance

Returns:boolean

true if method is for the same method as this method, false otherwise.

isPrivateback to summary
public final boolean isPrivate()

Returns whether or not this method is private.

Returns:boolean

true if this method is private

isProtectedback to summary
public final boolean isProtected()

Returns whether or not this method is protected.

Returns:boolean

true if this method is protected

isPublicback to summary
public final boolean isPublic()

Returns whether or not this method is public.

Returns:boolean

true if this method is public

isSameback to summary
public final boolean isSame(MetaMethod method)
Parameters
method:MetaMethod

the method to compare against

Returns:boolean

true if the given method has the same name, parameters, return type and modifiers but may be defined on another type

isStaticback to summary
public boolean isStatic()

Returns whether or not this method is static.

Returns:boolean

true if this method is static

processDoMethodInvokeExceptionback to summary
public final RuntimeException processDoMethodInvokeException(Exception e, Object object, Object[] argumentArray)

This method is called when an exception occurs while invoking this method.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this method

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.