Package com.singularsys.jep.functions
Class BinaryFunction
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.BinaryFunction
-
- All Implemented Interfaces:
PostfixMathCommandI
,java.io.Serializable
- Direct Known Subclasses:
ArcTangent2
,BigDecRoundSigFig
,Binomial
,BitAnd
,BitOr
,BitXor
,Comparative
,ComplexPFMC
,Cross
,Define
,Divide
,Dot
,FieldBinomial
,FieldMod
,FieldPower
,FieldRange
,Filter
,Fold
,JepTest.MyBinary
,Left
,Logical
,LogTwoArg
,LShift
,Map
,MatrixCross
,MatrixDiv
,MatrixMod
,MatrixPow
,MatrixSolve
,MatrixSub
,MatrixZeroMat
,Modulus
,NullWrappedBinary
,Polar
,Power
,Range
,Rank
,Remainder
,Right
,RShift
,Sort
,Subtract
,URShift
public abstract class BinaryFunction extends PostfixMathCommand
Convenient base class for binary functions. Defines anObject eval(Object l,Object r)
method for calculating the result.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description BinaryFunction()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.Object
eval(java.lang.Object l, java.lang.Object r)
static <T> BinaryFunction
instanceOf(java.lang.Class<T> type, java.util.function.BiFunction<T,T,? super java.lang.Object> fun)
Create a BinaryFunction from a lambda expression where both arguments are of a specified type.static BinaryFunction
instanceOf(java.util.function.BiFunction<java.lang.Object,java.lang.Object,? super java.lang.Object> fun)
Create a BinaryFunction from a lambda expression where arguments can be Objects.void
run(java.util.Stack<java.lang.Object> stack)
Callseval(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
-
-
-
-
Method Detail
-
run
public final void run(java.util.Stack<java.lang.Object> stack) throws EvaluationException
Callseval(Object, Object)
- Specified by:
run
in interfacePostfixMathCommandI
- Overrides:
run
in classPostfixMathCommand
- Parameters:
stack
- arguments for function- Throws:
EvaluationException
- if function cannot be evaluated
-
eval
public abstract java.lang.Object eval(java.lang.Object l, java.lang.Object r) throws EvaluationException
- Throws:
EvaluationException
-
instanceOf
public static BinaryFunction instanceOf(java.util.function.BiFunction<java.lang.Object,java.lang.Object,? super java.lang.Object> fun)
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
public static <T> BinaryFunction instanceOf(java.lang.Class<T> type, java.util.function.BiFunction<T,T,? super java.lang.Object> fun)
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 anIllegalParameterException
if 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
-
-