Package com.singularsys.jep.functions
Class BinaryFunction
java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.BinaryFunction
- All Implemented Interfaces:
PostfixMathCommandI,Serializable
- Direct Known Subclasses:
ArcTangent2,BigDecRoundSigFig,Binomial,BitAnd,BitOr,BitXor,Comparative,ComplexPFMC,Cross,Divide,Dot,JepTest.MyBinary,Left,Logical,LogTwoArg,LShift,Modulus,NullWrappedBinary,Polar,Power,Remainder,Right,RShift,Subtract,URShift
Convenient base class for binary functions.
Defines an
Object eval(Object l,Object r) method for calculating the result.- Author:
- Richard Morris
- See Also:
-
Field Summary
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Objectstatic <T> BinaryFunctioninstanceOf(Class<T> type, BiFunction<T, T, ? super Object> fun) Create a BinaryFunction from a lambda expression where both arguments are of a specified type.static BinaryFunctioninstanceOf(BiFunction<Object, Object, ? super Object> fun) Create a BinaryFunction from a lambda expression where arguments can be Objects.final voidCallseval(Object, Object)Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
Constructor Details
-
BinaryFunction
public BinaryFunction()
-
-
Method Details
-
run
Callseval(Object, Object)- Specified by:
runin interfacePostfixMathCommandI- Overrides:
runin classPostfixMathCommand- Parameters:
stack- arguments for function- Throws:
EvaluationException- if function cannot be evaluated
-
eval
- Throws:
EvaluationException
-
instanceOf
Create a BinaryFunction from a lambda expression where arguments can be Objects. For exampleBinaryFunction.instanceOf((x,y) -> ((Number) x).doubleValue() + ((Number) y).doubleValue())- Parameters:
fun- the lambda function- Returns:
- a new BinaryFunction instance
- Since:
- Jep 4.0
-
instanceOf
Create a BinaryFunction from a lambda expression where both arguments are of a specified type. For exampleBinaryFunction.instanceOf(Integer.class, (x,y) -> x * y)Theeval(Object,Object)method will throw anIllegalParameterExceptionif either argument is not of the correct type.- Type Parameters:
T- type of arguments and return value- Parameters:
type- type of the argumentsfun- the lambda function- Returns:
- a new BinaryFunction instance
- Since:
- Jep 4.0
-