Class NullWrappedFunctionFactory

java.lang.Object
com.singularsys.jep.misc.nullwrapper.NullWrappedFunctionFactory
All Implemented Interfaces:
JepComponent, Serializable

public class NullWrappedFunctionFactory extends Object implements JepComponent
A factory to create the appropriate type of wrapped function.
Author:
Richard Morris
See Also:
  • Constructor Details

    • NullWrappedFunctionFactory

      public NullWrappedFunctionFactory()
  • Method Details

    • getWrappedFunction

      public PostfixMathCommandI getWrappedFunction(PostfixMathCommandI fun)
      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 implements CallbackEvaluationI then it cannot be wrapped and null is returned.
      • If fun implements NullWrappedFunctionI then it is already wrapped and fun is returned.
      • If fun implements UnaryFunction then it is wrapped by NullWrapperUnary which is returned.
      • If fun implements BinaryFunction then it is wrapped by NullWrapperBinary which is returned.
      • If fun implements NaryFunction then it is wrapped by NullWrapperNary which is returned.
      • If fun implements NaryBinaryFunction then it is wrapped by NullWrapperNaryBinary which is returned.
      • If fun has zero arguments then it does not need to wrap functions and fun.
      • If fun implements PostfixMathCommand then it is wrapped by NullWrapperPfmc which is returned.
      • Otherwise fun is returned.
      Parameters:
      fun - the function to be wrapped
      Returns:
      the wrapped function or null see above for details
    • getSpecialFunction

      protected PostfixMathCommandI getSpecialFunction(PostfixMathCommandI fun)
      Handles special functions. Subclasses can override this method to add treatment of other special functions. This method performs the following actions:
      • If and TernaryConditional are replaced by NullWrappedIf.
      • LazyLogical functions are replaced by NullLazyLogical.
      • Increment functions which extend AbstractInc are wrapped by NullAbstractInc
      • 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

      public JepComponent getLightWeightInstance()
      Description copied from interface: JepComponent
      Gets a light-weight instance suitable for using in multiple threads.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Returns:
      this
    • init

      public void init(Jep jep)
      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 interface JepComponent
      Parameters:
      jep - the current Jep instance