Groovy 2.2.1

org.codehaus.groovy.runtime.callsite
[Java] Class BooleanClosureWrapper

java.lang.Object
  org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper

public class BooleanClosureWrapper
extends Object

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 DefaultTypeTransformation.castToBoolean. The purpose of this class is to avoid the slow "asBoolean" call in that method. BooleanReturningMethodInvoker is used for caching.

Authors:
Jochen "blackdrag" Theodorou


Constructor Summary
BooleanClosureWrapper(Closure wrapped)

 
Method Summary
boolean call(Object... args)

normal closure call

boolean callForMap(Map.Entry entry)

Bridge for a call based on a map entry.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Constructor Detail

BooleanClosureWrapper

public BooleanClosureWrapper(Closure wrapped)


 
Method Detail

call

public boolean call(Object... args)
normal closure call


callForMap

public boolean callForMap(Map.Entry 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.


 

Copyright © 2003-2013 The Codehaus. All rights reserved.