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,
java.lang.Object... arguments) |
CurriedClosure(int index,
Closure<V> uncurriedClosure,
java.lang.Object... arguments) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
java.lang.Object |
getDelegate() |
java.lang.Class[] |
getParameterTypes() |
int |
getResolveStrategy()
Gets the strategy which the closure users to resolve methods and properties
|
java.lang.Object[] |
getUncurriedArguments(java.lang.Object... arguments) |
void |
setDelegate(java.lang.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 CurriedClosure(int index, Closure<V> uncurriedClosure, java.lang.Object... arguments)
public java.lang.Object[] getUncurriedArguments(java.lang.Object... arguments)
public void setDelegate(java.lang.Object delegate)
Closure
setDelegate
in class Closure<V>
delegate
- the new delegatepublic java.lang.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 java.lang.Class[] getParameterTypes()
getParameterTypes
in class Closure<V>