In our first example we will get value of a demo.motor.coverage.position parameter for given coverage code. The definition of the parameter is as follows:
The parameter has two columns. One IN (code) and one OUT (position). For each IN value there is a corresponding OUT value, e.g. COMP -> 7.
To get value from Hyperon engine simply inject Hyperon Engine (part of Hyperon Runtime Library) into your Spring Component/Service:
prepare a context:
and execute get method:
The result of the get method is an object of ParamValue class. This class provides convenient accessor methods for individual data types, e.g. getString, getBigDecimal, getDate, getDateTime, getLocalDate, getLocalDateTime, getInteger, getBoolean. The argument for these accessor methods is OUT column code that we are interested in getting.
Explore more options with examples on GitHub.
While getting parameter value we do not pass input values for each IN column, e.g. for code column. That is responsibility of a context which acts as source of input values for parameters and functions. In our example context provides value for code column. Columns are matched via value source property.
To design robust contexts read carefully Context concept and Implementing execution context.
In the next example let's see how we can handle situation where we expect engine get call to return more than one row. The definition of the parameter is as follows:
prepare a context:
and execute get method:
Now we can simply iterate over returned matrix:
Parameter definition and matrix is loaded from database only once. Subsequent calls to the get method will use cached values. For large parameters' matrices and production environments prefetching can be setup to load parameters into memory while starting-up the application.