Class ChainableGeneralFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.misc.overloadedfunctions.OverloadedFunctionByStructure
com.singularsys.extensions.chained.ChainableGeneralFunction
- All Implemented Interfaces:
ChainedFunctionI,DirtyFunction,CallbackEvaluationI,JepComponent,PostfixMathCommandI,Serializable
public class ChainableGeneralFunction
extends OverloadedFunctionByStructure
implements ChainedFunctionI, DirtyFunction
Converts a
NaryFunction so it can be used in a chain or directly as Nary function.
If the number of arguments is 1, then the a ChainedNaryFunction is used,
otherwise the function is used normally.- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.misc.overloadedfunctions.OverloadedFunctionByStructure
argTest, function1, function2, nf, otFields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, description, name, NaN, numberOfParameters -
Constructor Summary
ConstructorsConstructorDescriptionChainableGeneralFunction(ChainedFunctionI function1, PostfixMathCommandI function2, Predicate<Node> argTest) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionEvaluate a chained function using an additional argument.Get the chained version of the function.Return a description of the function from the properties file.Gets a light-weight instance suitable for using in multiple threads.Get the un-chained function.Methods inherited from class com.singularsys.jep.misc.overloadedfunctions.OverloadedFunctionByStructure
checkNumberOfParameters, evaluate, getFunction1, getFunction2, getFunctionFor, getNumberOfParameters, getPredicate, initMethods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, getDescription, getDescriptionWithType, getName, run, setCurNumberOfParameters, setDescription, setName, toString, toString
-
Constructor Details
-
ChainableGeneralFunction
public ChainableGeneralFunction(ChainedFunctionI function1, PostfixMathCommandI function2, Predicate<Node> argTest) Constructor.- Parameters:
function1- the function to use in a chain, must implementChainedFunctionIfunction2- the function to use when not in a chain, must implementPostfixMathCommandIargTest- a predicate that tests the structure of the parse tree, the first function is used if this returns true.
-
-
Method Details
-
apply
Description copied from interface:ChainedFunctionIEvaluate a chained function using an additional argument.- Specified by:
applyin interfaceChainedFunctionI- Parameters:
ev- the evaluatornode- top node of functionarg- additional argument from previous element in the chain- Returns:
- Throws:
EvaluationException
-
getLightWeightInstance
Description copied from interface:JepComponentGets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstancein interfaceJepComponent- Overrides:
getLightWeightInstancein classOverloadedFunctionByStructure- Returns:
- either a new instance, null or 'this'.
-
getDescription
Description copied from class:PostfixMathCommandReturn a description of the function from the properties file. The property name is the class name followed by ".description". The property is found using theJepMessagesclass, which can be configured to add additional properties files. IfPostfixMathCommand.setDescription(String)has been called, return the description set by that method instead.- Specified by:
getDescriptionin interfacePostfixMathCommandI- Overrides:
getDescriptionin classOverloadedFunctionByStructure- Returns:
- the description of the function
-
getRootFunction
Get the un-chained function.- Returns:
- the second argument in the constructor
-
getChainedFunction
Get the chained version of the function.- Returns:
- the chained function
-