Class ConstructorMethod
java.lang.Object
org.apache.commons.jexl3.internal.introspection.ConstructorMethod
- All Implemented Interfaces:
JexlMethod
A JexlMethod that wraps a constructor.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConstructorMethoddiscover(Introspector is, Object ctorHandle, Object... args) Discovers a class constructor and wrap it as a JexlMethod.Class<?> returns the return type of the method invoked.Invocation method, called when the method invocation should be performed and a value returned.booleanSpecifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.booleanChecks whether a tryInvoke return value indicates a failure or not.Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.
-
Field Details
-
ctor
The wrapped constructor.
-
-
Constructor Details
-
ConstructorMethod
ConstructorMethod(Constructor<?> theCtor) Creates a constructor method.- Parameters:
theCtor- the constructor to wrap
-
-
Method Details
-
discover
Discovers a class constructor and wrap it as a JexlMethod.- Parameters:
is- the introspectorctorHandle- a class or class nameargs- constructor arguments- Returns:
- a
JexlMethod
-
getReturnType
Description copied from interface:JexlMethodreturns the return type of the method invoked.- Specified by:
getReturnTypein interfaceJexlMethod- Returns:
- return type
-
invoke
Description copied from interface:JexlMethodInvocation method, called when the method invocation should be performed and a value returned.- Specified by:
invokein interfaceJexlMethod- Parameters:
obj- the objectparams- method parameters.- Returns:
- the result
- Throws:
Exception- on any error.
-
isCacheable
public boolean isCacheable()Description copied from interface:JexlMethodSpecifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.- Specified by:
isCacheablein interfaceJexlMethod- Returns:
- true if can be reused for this class, false if not
-
tryFailed
Description copied from interface:JexlMethodChecks whether a tryInvoke return value indicates a failure or not.Usage is :
Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}- Specified by:
tryFailedin interfaceJexlMethod- Parameters:
rval- the value returned by tryInvoke- Returns:
- true if tryInvoke failed, false otherwise
-
tryInvoke
Description copied from interface:JexlMethodAttempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments. Related to isCacheable since this method is often used with cached JexlMethod instances.- Specified by:
tryInvokein interfaceJexlMethod- Parameters:
name- the method nameobj- the object to invoke the method uponargs- the method arguments- Returns:
- the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.
-