public final class CurriedClosure extends Closure
curry()
, rcurry()
or
ncurry()
methods on Closure
.
Typical usages:
// normal usage def unitAdder = { first, second, unit -> "${first + second} $unit" } assert unitAdder(10, 15, "minutes") == "25 minutes" assert unitAdder.curry(60)(15, "minutes") == "75 minutes" def minuteAdder = unitAdder.rcurry("minutes") assert minuteAdder(15, 60) == "75 minutes" // explicit creation import org.codehaus.groovy.runtime.CurriedClosure assert new CurriedClosure(unitAdder, 45)(15, "minutes") == "60 minutes" assert new CurriedClosure(unitAdder, "six", "ty")("minutes") == "sixty minutes"
DELEGATE_FIRST, DELEGATE_ONLY, DONE, maximumNumberOfParameters, OWNER_FIRST, OWNER_ONLY, parameterTypes, SKIP, TO_SELF
Constructor and Description |
---|
CurriedClosure(Closure uncurriedClosure,
int i)
Deprecated.
|
CurriedClosure(Closure uncurriedClosure,
Object[] arguments) |
CurriedClosure(int index,
Closure uncurriedClosure,
Object[] arguments) |
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
Object |
getDelegate() |
Class[] |
getParameterTypes() |
int |
getResolveStrategy()
Gets the strategy which the closure users to resolve methods and properties
|
Object[] |
getUncurriedArguments(Object[] arguments) |
void |
setDelegate(Object delegate)
Allows the delegate to be changed such as when performing markup building
|
void |
setResolveStrategy(int resolveStrategy)
Sets the strategy which the closure uses to resolve property references.
|
asWritable, call, call, call, curry, getDirective, getMaximumNumberOfParameters, getOwner, getProperty, getThisObject, isCase, ncurry, rcurry, run, setDirective, setProperty, throwRuntimeException
getMetaClass, invokeMethod, setMetaClass
@Deprecated public CurriedClosure(Closure uncurriedClosure, int i)
public void setDelegate(Object delegate)
Closure
setDelegate
in class Closure
delegate
- the new delegatepublic Object getDelegate()
getDelegate
in class Closure
public void setResolveStrategy(int resolveStrategy)
Closure
setResolveStrategy
in class Closure
resolveStrategy
- The resolve strategy to setClosure.DELEGATE_FIRST
,
Closure.DELEGATE_ONLY
,
Closure.OWNER_FIRST
,
Closure.OWNER_ONLY
,
Closure.TO_SELF
public int getResolveStrategy()
Closure
getResolveStrategy
in class Closure
Closure.DELEGATE_FIRST
,
Closure.DELEGATE_ONLY
,
Closure.OWNER_FIRST
,
Closure.OWNER_ONLY
,
Closure.TO_SELF
public Class[] getParameterTypes()
getParameterTypes
in class Closure