@Deprecated(since = "6.0.0", forRemoval = true)
public class BooleanReturningMethodInvoker
extends Object
Helper class for internal use only. This allows to call a given method and convert the result to a boolean. It will do this by caching the method call 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. The nature of this class allows a per instance caching instead of a per class caching like the normal CallSiteArray logic.
| Constructor and description |
|---|
BooleanReturningMethodInvoker()Caches a null method name and asBoolean. |
BooleanReturningMethodInvoker(String methodName)Caches methodName and asBoolean on a
CallSiteArray owned by this class. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
convertToBoolean(Object arg)Returns false for null and the unboxed value for a Boolean.
|
|
public boolean |
invoke(Object receiver, Object args)Calls the cached method on receiver with args and
converts the result with convertToBoolean(Object).
|
Caches a null method name and asBoolean.
Caches methodName and asBoolean on a
CallSiteArray owned by this class.
Returns false for null and the unboxed value for a Boolean.
Any other value is sent through the cached asBoolean site and
cast to Boolean. A failure of that call is rethrown unchecked.
Calls the cached method on receiver with args and
converts the result with convertToBoolean(Object).
Any thrown exception is rethrown unchecked.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.