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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets a light-weight instance suitable for using in multiple threads.protected PostfixMathCommandIHandles special functions.Gets a wrapped function, returns a function which will handle null values correctly.voidInitialize 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
funimplementsCallbackEvaluationIthen it cannot be wrapped and null is returned. - If
funimplementsNullWrappedFunctionIthen it is already wrapped andfunis returned. - If
funimplementsUnaryFunctionthen it is wrapped byNullWrapperUnarywhich is returned. - If
funimplementsBinaryFunctionthen it is wrapped byNullWrapperBinarywhich is returned. - If
funimplementsNaryFunctionthen it is wrapped byNullWrapperNarywhich is returned. - If
funimplementsNaryBinaryFunctionthen it is wrapped byNullWrapperNaryBinarywhich is returned. - If
funhas zero arguments then it does not need to wrap functions andfun. - If
funimplementsPostfixMathCommandthen it is wrapped byNullWrapperPfmcwhich is returned. - Otherwise
funis 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:IfandTernaryConditionalare replaced byNullWrappedIf.LazyLogicalfunctions are replaced byNullLazyLogical.- Increment functions which extend
AbstractIncare wrapped byNullAbstractInc Assign,List,Ele,IsNull, all handle null correctly so the original function is returned.- For
Case,Switch,SwitchDefaultinstances 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:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- this
-
init
Description copied from interface:JepComponentInitialize 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-