public class ClosureMetaMethod
extends MetaMethod
implements ClosureInvokingMethod
A MetaMethod that accepts a closure in the constructor which is invoked when the MetaMethod is called. The delegate of the closure is set to the instance that the MetaMethod is invoked on when called.
| Fields inherited from class | Fields |
|---|---|
class MetaMethod |
EMPTY_ARRAY |
| Constructor and description |
|---|
ClosureMetaMethod(String name, Closure c, CachedMethod doCall)Constructs a new ClosureMetaMethod with the specified name and closure. |
ClosureMetaMethod(String name, Class declaringClass, Closure c, CachedMethod doCall)Constructs a new ClosureMetaMethod with the specified name, declaring class, and closure. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static ClosureMetaMethod |
copy(ClosureMetaMethod closureMethod)Creates a copy of the given ClosureMetaMethod. |
|
public static List<MetaMethod> |
createMethodList(String name, Class declaringClass, Closure closure)Creates a list of MetaMethod instances from the given closure. |
|
public Closure |
getClosure()Retrieves the closure that is invoked by this MetaMethod |
|
public CachedClass |
getDeclaringClass()Returns the cached class that declares this meta method. |
|
public CachedMethod |
getDoCall()Returns the cached method that represents the closure's doCall method. |
|
public int |
getModifiers()Returns the modifiers for this method. |
|
public String |
getName()Returns the name of this closure meta method. |
|
public Class |
getReturnType()Returns the return type of this method. |
|
public Object |
invoke(Object object, Object[] arguments)Invokes the closure with the given arguments. |
| Methods inherited from class | Name |
|---|---|
class MetaMethod |
checkParameters, clone, doMethodInvoke, equal, equal, getDeclaringClass, getDescriptor, getModifiers, getMopName, getName, getReturnType, getSignature, invoke, isAbstract, isCacheable, isDefault, isMethod, isSame, processDoMethodInvokeException, toString |
class ParameterTypes |
coerceArgumentsToClasses, correctArguments, getNativeParameterTypes, getPT, getParameterTypes, isValidExactMethod, isValidExactMethod, isValidMethod, isValidMethod, isVargsMethod, isVargsMethod, setParametersTypes |
Constructs a new ClosureMetaMethod with the specified name and closure. The declaring class is obtained from the closure's owner.
name - the name of the methodc - the closure to invoke when this method is calleddoCall - the cached method representing the closure's doCall methodConstructs a new ClosureMetaMethod with the specified name, declaring class, and closure.
name - the name of the methoddeclaringClass - the class that declares this meta methodc - the closure to invoke when this method is calleddoCall - the cached method representing the closure's doCall methodCreates a copy of the given ClosureMetaMethod. If the method is a MethodClosureMetaMethod, returns a new MethodClosureMetaMethod; otherwise returns a new ClosureMetaMethod.
closureMethod - the closure meta method to copyCreates a list of MetaMethod instances from the given closure. Handles MethodClosure, GeneratedClosure, and anonymous closures appropriately.
name - the name of the methoddeclaringClass - the class that declares this meta methodclosure - the closure to create meta methods fromRetrieves the closure that is invoked by this MetaMethod
Returns the cached class that declares this meta method.
Returns the cached method that represents the closure's doCall method.
Returns the modifiers for this method.
Returns the name of this closure meta method.
Returns the return type of this method.
Invokes the closure with the given arguments. The closure's delegate is set to the object on which this method is being invoked.
object - the object on which the method is invoked (becomes the closure's delegate)arguments - the arguments to pass to the closureCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.