Introduction to FormulaX, the runtime calculation framework

I have spent my free time to develop a runtime calculation framework. This framework you can define the execution condition of the formula so that it will be performed if the condition is matched. The source code is at the github.

You can define the variable in the configuration using properties or object method. This is an implementation example

//config.properties
start.date.anniversary=2018-08-07T00:00:00+0000
end.date.anniversary=2018-08-31T23:59:59+0000
--------------------------------------------------------------------
<Formula id = "AnniversaryDiscount20" name = "Anniversary discount 20%"
start-date = "${start.date.anniversary}"
end-date = "${end.date.anniversary}">
<When>
<Condition logic = "Or">
<Condition value1 = "@{totalPayment}" logic = "GreaterThanOrEqual" value2 = "10000.00" />
<Condition logic = "And">
<Condition value1 = "@{totalPayment}" logic = "GreaterThanOrEqual" value2 = "1000.00" />
<Condition value1 = "@{totalItems}" logic = "GreaterThanOrEqual" value2 = "5.00" />
</Condition>
</Condition>
</When>
<Perform>
<Multiply value = "0.80" to = "@{totalPayment}" />
</Perform>
</Formula>
--------------------------------------------------------------------
public class Order {

public double getTotalPayment() {
return 9999.00;
}

public double getTotalItems() {
return 7.00;
}
}

You can load the formula using FormulaFactory, then send the order object to Formula.calculate(order). From the code above, the condition will match, and calculate 9999.00 x 0.80. Finally, the result return 7999.20.