Top Description Fields Constructors Methods
org.codehaus.groovy.runtime.callsite

public Class BooleanClosureWrapper

extends Object
Class Inheritance
Imports
groovy.lang.Closure, java.util.Map, .Map.Entry

Helper class for internal use only. This allows to call a Closure and convert the result to a boolean. It will do this by caching the possible "doCall" as well as the "asBoolean" in CallSiteArray fashion. "asBoolean" will not be called if the result is null or a Boolean. In case of null we return false and in case of a Boolean we simply unbox. This logic is designed after the one present in org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation#castToBoolean(Object). The purpose of this class is to avoid the slow "asBoolean" call in that method. BooleanReturningMethodInvoker is used for caching.

Field Summary

Modifier and TypeField and Description
private final BooleanReturningMethodInvoker
private final int
private final Closure<V>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
call(Object... args)

normal closure call

public <K, V> boolean
callForMap(Map.Entry<K, V> entry)

Bridge for a call based on a map entry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bmiback to summary
private final BooleanReturningMethodInvoker bmi
numberOfArgumentsback to summary
private final int numberOfArguments
wrappedback to summary
private final Closure<V> wrapped

Constructor Detail

BooleanClosureWrapperback to summary
public BooleanClosureWrapper(Closure<V> wrapped)

Method Detail

callback to summary
public boolean call(Object... args)

normal closure call

callForMapback to summary
public <K, V> boolean callForMap(Map.Entry<K, V> entry)

Bridge for a call based on a map entry. If the call is done on a Closure taking one argument, then we give in the Entry, otherwise we will give in the key and value.