In this example we will call a simple function to calculate a premium. Premium value is based on input data as follows:
Function returns a final premium amount.
Formula given:
Definition of the demo.insurance.calcpremium is as follows:
To call function simply inject Hyperon Engine (part of Hyperon Runtime Library) into your Spring Component/Service:
prepare a context:
and execute call method:
Please mind that while executing function we do not directly pass function arguments, e.g. policy.premiumPerDay, policy.startDate, policy.endDate. Hyperon Engine will query context for only necessary input data (with lazing querying approach). The responsibility of the context is to answer those queries.
To design robust contexts read carefully Context concept and Implementing execution context.
The output will be as follows:
2) Debug output from the function itself
3) Final value
Loading and compiling (1) is done only once. Subsequent call to a function would go straight to execution.