Package com.codetaco.math
Class Equ<T>
- java.lang.Object
-
- com.codetaco.math.Equ<T>
-
public class Equ<T> extends Object
Create an instance of this class and send it an evaluate() message. The result will always be an instance of Double or String or ZonedDateTime.
You can also register your own functions and operators by calling the static methods registerFunction and registerOperator. These add to a static Map so there are then available for the duration of your application.
A support instance can be handed to an instance of Equ with the setSupport() method. This must be done prior to calling evaluate. When a variable is found in the equation then the support instance is asked to instantiate the variable. It is expected that it will do what is necessary to come up with it. The test cases show a support instance that maintains a local Map of variable name / value pairs. But a database could be used as well.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Equ.Builder<B>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <B> Equ.Builder<B>
builder(Class<B> returnType)
T
evaluate()
Double
getDouble(String variableName)
Integer
getInteger(String variableName)
Long
getLong(String variableName)
String
getString(String variableName)
ZonedDateTime
getZonedDateTime(String variableName)
String
showRPN()
String
toString()
void
variable(String variableName, Object value)
-
-
-
Method Detail
-
builder
public static <B> Equ.Builder<B> builder(Class<B> returnType)
-
evaluate
public T evaluate()
-
getZonedDateTime
public ZonedDateTime getZonedDateTime(String variableName)
-
showRPN
public String showRPN()
-
-