com.singularsys.jep.misc.nullwrapper

## Class NullWrappedFunctionFactory

- java.lang.Object
- - com.singularsys.jep.misc.nullwrapper.NullWrappedFunctionFactory

- All Implemented Interfaces:
    JepComponent, java.io.Serializable

      public class NullWrappedFunctionFactory
      extends java.lang.Object
      implements JepComponent

  A factory to create the appropriate type of wrapped function.
  Author:
    Richard Morris
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NullWrappedFunctionFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JepComponent` | `getLightWeightInstance()` Gets a light-weight instance suitable for using in multiple threads.
    `protected PostfixMathCommandI` | `getSpecialFunction(PostfixMathCommandI fun)` Handles special functions.
    `PostfixMathCommandI` | `getWrappedFunction(PostfixMathCommandI fun)` Gets a wrapped function, returns a function which will handle null values correctly.
    `void` | `init(Jep jep)` Initialize the component.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NullWrappedFunctionFactory

          public NullWrappedFunctionFactory()

  - ### Method Detail

    - #### 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 alread 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 methods 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 methods 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

Copyright © 2018 Singular Systems http://www.singularsys.com/jep