Class ConstructorMethod
- java.lang.Object
-
- org.apache.commons.jexl3.internal.introspection.ConstructorMethod
-
- All Implemented Interfaces:
JexlMethod
public final class ConstructorMethod extends java.lang.Object implements JexlMethod
A JexlMethod that wraps a constructor.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.Constructor<?>
ctor
The wrapped constructor.
-
Constructor Summary
Constructors Constructor Description ConstructorMethod(java.lang.reflect.Constructor<?> theCtor)
Creates a constructor method.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConstructorMethod
discover(Introspector is, java.lang.Object ctorHandle, java.lang.Object... args)
Discovers a class constructor and wrap it as a JexlMethod.java.lang.Class<?>
getReturnType()
returns the return type of the method invoked.java.lang.Object
invoke(java.lang.Object obj, java.lang.Object... params)
Invocation method, called when the method invocation should be performed and a value returned.boolean
isCacheable()
Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.boolean
tryFailed(java.lang.Object rval)
Checks whether a tryInvoke return value indicates a failure or not.java.lang.Object
tryInvoke(java.lang.String name, java.lang.Object obj, java.lang.Object... args)
Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.
-
-
-
Method Detail
-
discover
public static ConstructorMethod discover(Introspector is, java.lang.Object ctorHandle, java.lang.Object... args)
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
public java.lang.Class<?> getReturnType()
Description copied from interface:JexlMethod
returns the return type of the method invoked.- Specified by:
getReturnType
in interfaceJexlMethod
- Returns:
- return type
-
invoke
public java.lang.Object invoke(java.lang.Object obj, java.lang.Object... params) throws java.lang.Exception
Description copied from interface:JexlMethod
Invocation method, called when the method invocation should be performed and a value returned.- Specified by:
invoke
in interfaceJexlMethod
- Parameters:
obj
- the objectparams
- method parameters.- Returns:
- the result
- Throws:
java.lang.Exception
- on any error.
-
isCacheable
public boolean isCacheable()
Description copied from interface:JexlMethod
Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.- Specified by:
isCacheable
in interfaceJexlMethod
- Returns:
- true if can be reused for this class, false if not
-
tryFailed
public boolean tryFailed(java.lang.Object rval)
Description copied from interface:JexlMethod
Checks whether a tryInvoke return value indicates a failure or not.Usage is :
Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}
- Specified by:
tryFailed
in interfaceJexlMethod
- Parameters:
rval
- the value returned by tryInvoke- Returns:
- true if tryInvoke failed, false otherwise
-
tryInvoke
public java.lang.Object tryInvoke(java.lang.String name, java.lang.Object obj, java.lang.Object... args)
Description copied from interface:JexlMethod
Attempts 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:
tryInvoke
in 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.
-
-