Class NullWrappedFunctionFactory
java.lang.Object
com.singularsys.jep.misc.nullwrapper.NullWrappedFunctionFactory
- All Implemented Interfaces:
JepComponent
,Serializable
A factory to create the appropriate type of wrapped function.
- Author:
- Richard Morris
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets a light-weight instance suitable for using in multiple threads.protected PostfixMathCommandI
Handles special functions.Gets a wrapped function, returns a function which will handle null values correctly.void
Initialize the component.
-
Constructor Details
-
NullWrappedFunctionFactory
public NullWrappedFunctionFactory()
-
-
Method Details
-
getWrappedFunction
Gets a wrapped function, returns a function which will handle null values correctly. This method:- Calls
getSpecialFunction(PostfixMathCommandI)
and returns any non null results. - If
fun
implementsCallbackEvaluationI
then it cannot be wrapped and null is returned. - If
fun
implementsNullWrappedFunctionI
then it is already wrapped andfun
is returned. - If
fun
implementsUnaryFunction
then it is wrapped byNullWrapperUnary
which is returned. - If
fun
implementsBinaryFunction
then it is wrapped byNullWrapperBinary
which is returned. - If
fun
implementsNaryFunction
then it is wrapped byNullWrapperNary
which is returned. - If
fun
implementsNaryBinaryFunction
then it is wrapped byNullWrapperNaryBinary
which is returned. - If
fun
has zero arguments then it does not need to wrap functions andfun
. - If
fun
implementsPostfixMathCommand
then it is wrapped byNullWrapperPfmc
which is returned. - Otherwise
fun
is returned.
- Parameters:
fun
- the function to be wrapped- Returns:
- the wrapped function or null see above for details
- Calls
-
getSpecialFunction
Handles special functions. Subclasses can override this method to add treatment of other special functions. This method performs the following actions:If
andTernaryConditional
are replaced byNullWrappedIf
.LazyLogical
functions are replaced byNullLazyLogical
.- Increment functions which extend
AbstractInc
are wrapped byNullAbstractInc
Assign
,List
,Ele
,IsNull
, all handle null correctly so the original function is returned.- For
Case
,Switch
,SwitchDefault
instances of these which handle nulls correctly are returned.
- Parameters:
fun
- original function- Returns:
- the new function or null if no special function found.
-
getLightWeightInstance
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- this
-
init
Description copied from interface:JepComponent
Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.- Specified by:
init
in interfaceJepComponent
- Parameters:
jep
- the current Jep instance
-