public final class CurriedClosure<V> extends Closure<V>
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, IDENTITY, maximumNumberOfParameters, OWNER_FIRST, OWNER_ONLY, parameterTypes, SKIP, TO_SELF
Constructor and Description |
---|
CurriedClosure(Closure<V> uncurriedClosure,
Object... arguments) |
CurriedClosure(int index,
Closure<V> uncurriedClosure,
Object... arguments) |
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
Object |
getDelegate() |
Class[] |
getParameterTypes() |
int |
getResolveStrategy()
Gets the strategy which the closure uses 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 and methods.
|
asWritable, call, call, call, curry, curry, dehydrate, getDirective, getMaximumNumberOfParameters, getOwner, getProperty, getThisObject, isCase, leftShift, leftShift, memoize, memoizeAtLeast, memoizeAtMost, memoizeBetween, ncurry, ncurry, rcurry, rcurry, rehydrate, rightShift, run, setDirective, setProperty, throwRuntimeException, trampoline, trampoline
getMetaClass, invokeMethod, setMetaClass
public void setDelegate(Object delegate)
Closure
setDelegate
in class Closure<V>
delegate
- the new delegatepublic Object getDelegate()
getDelegate
in class Closure<V>
public void setResolveStrategy(int resolveStrategy)
Closure
setResolveStrategy
in class Closure<V>
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<V>
Closure.DELEGATE_FIRST
,
Closure.DELEGATE_ONLY
,
Closure.OWNER_FIRST
,
Closure.OWNER_ONLY
,
Closure.TO_SELF
public Class[] getParameterTypes()
getParameterTypes
in class Closure<V>