Top Description Fields Constructors Methods
groovy.lang

pack-priv final Class TrampolineClosure<V>

extends Closure<V>
Class Inheritance

A TrampolineClosure wraps a closure that needs to be executed on a functional trampoline. Upon calling, a TrampolineClosure will call the original closure waiting for its result. If the outcome of the call is another instance of a TrampolineClosure, created perhaps as a result to a call to the TrampolineClosure.trampoline() method, the TrampolineClosure will again be invoked. This repetitive invocation of returned TrampolineClosure instances will continue until a value other than TrampolineClosure is returned. That value will become the final result of the trampoline.

Field Summary

Modifier and TypeField and Description
private final Closure<V>
private static final long
Inherited from groovy.lang.Closure:
DELEGATE_FIRSTDELEGATE_ONLYDONEIDENTITYmaximumNumberOfParametersOWNER_FIRSTOWNER_ONLYparameterTypesSKIPTO_SELF

Constructor Summary

AccessConstructor and Description
pack-priv
TrampolineClosure(final Closure<V> original)

Method Summary

Modifier and TypeMethod and Description
public V

Returns:

The final result of the trampoline
call
()

Overrides groovy.lang.Closure.call.

Implements java.util.concurrent.Callable.call.

Starts the trampoline loop and calls the wrapped closure as the first step.
public V

Returns:

The final result of the trampoline
call
(final Object
could be a single value or a List of values
arguments
)

Overrides groovy.lang.Closure.call.

Starts the trampoline loop and calls the wrapped closure as the first step.
public V

Returns:

The final result of the trampoline
call
(final Object... args)

Overrides groovy.lang.Closure.call.

Starts the trampoline loop and calls the wrapped closure as the first step.
public int
public Class<T>[]
getParameterTypes()

Overrides groovy.lang.Closure.getParameterTypes.

Delegates to the wrapped closure
private V
loop(final Object lastResult)

public Closure<V>

Returns:

An instance of TrampolineClosure wrapping the original closure after currying.
trampoline
(final Object...
Parameters to curry to the underlying closure.
args
)

Overrides groovy.lang.Closure.trampoline.

Builds a trampolined variant of the current closure.
public Closure<V>

Returns:

An instance of TrampolineClosure wrapping the original closure.
trampoline
()

Overrides groovy.lang.Closure.trampoline.

Returns itself, since it is a good enough trampolined variant of the current closure.
Inherited from groovy.lang.Closure:
andThenandThenSelfandThenSelfasWritableclonecomposecomposeSelfcomposeSelfcurrycurrydehydrategetDelegategetDirectivegetOwnergetPropertygetResolveStrategygetThisObjectisCaseleftShiftleftShiftmemoizememoizeAtLeastmemoizeAtMostmemoizeBetweenncurryncurryrcurryrcurryrehydraterightShiftrunsetDelegatesetDirectivesetPropertysetResolveStrategythrowRuntimeException

Field Detail

originalback to summary
private final Closure<V> original
serialVersionUIDback to summary
private static final long serialVersionUID

Hides groovy.lang.Closure.serialVersionUID.

Constructor Detail

TrampolineClosureback to summary
pack-priv TrampolineClosure(final Closure<V> original)

Method Detail

callback to summary
public V call()

Overrides groovy.lang.Closure.call.

Implements java.util.concurrent.Callable.call.

Starts the trampoline loop and calls the wrapped closure as the first step.

Returns:V

The final result of the trampoline

Annotations
@Override
callback to summary
public V call(final Object arguments)

Overrides groovy.lang.Closure.call.

Starts the trampoline loop and calls the wrapped closure as the first step.

Parameters
arguments:Object

Doc from groovy.lang.Closure.call.

could be a single value or a List of values

Returns:V

The final result of the trampoline

Annotations
@Override
callback to summary
public V call(final Object... args)

Overrides groovy.lang.Closure.call.

Starts the trampoline loop and calls the wrapped closure as the first step.

Returns:V

The final result of the trampoline

Annotations
@Override
getMaximumNumberOfParametersback to summary
public int getMaximumNumberOfParameters()

Overrides groovy.lang.Closure.getMaximumNumberOfParameters.

Delegates to the wrapped closure

Returns:int

Doc from groovy.lang.Closure.getMaximumNumberOfParameters.

the maximum number of parameters a doCall method of this closure can take

Annotations
@Override
getParameterTypesback to summary
public Class<T>[] getParameterTypes()

Overrides groovy.lang.Closure.getParameterTypes.

Delegates to the wrapped closure

Returns:Class<T>[]

Doc from groovy.lang.Closure.getParameterTypes.

the parameter types of the longest doCall method of this closure

Annotations
@Override
loopback to summary
private V loop(final Object lastResult)
trampolineback to summary
public Closure<V> trampoline(final Object... args)

Overrides groovy.lang.Closure.trampoline.

Builds a trampolined variant of the current closure.

Parameters
args:Object[]

Parameters to curry to the underlying closure.

Returns:Closure<V>

An instance of TrampolineClosure wrapping the original closure after currying.

Annotations
@Override
trampolineback to summary
public Closure<V> trampoline()

Overrides groovy.lang.Closure.trampoline.

Returns itself, since it is a good enough trampolined variant of the current closure.

Returns:Closure<V>

An instance of TrampolineClosure wrapping the original closure.

Annotations
@Override