Note: This example is somewhat more advanced than the example “Create a Custom Function To Capitalize Text” and builds on the concepts already demonstrated there.
By default a custom function does not see unknown and uncertain value, and their presence will automatically return unknown or uncertain as the result. However some functions can return a value even when some parameters are unknown.
In this example, a function is required to assume some default value in the case where a question hasn’t been answered (ie. when it is unknown).
Note: Because this example function transforms unknown values into known values, it may cause a rulebase to prematurely draw conclusions when required values have not been asked. If a distinction is required between a ‘genuine’ conclusion and a ‘default’ conclusion, use of this function may not be suitable.
The function is defined inside the extension.xml file as follows:
<extension>
<functions>
<function name="DefaultNumber" return-type="number">
<arg name="value" type="number"/>
<arg name="default" type="number"/>
<handler platform="java"
class="com.oracle.determinations.examples.DefaultFunction"/>
<handler platform="dotnet"
class="Oracle.Determinations.Examples.DefaultFunction"/>
</function>
</functions>
</extension>
This file is saved inside an extension folder, which is then itself copied into the project’s “extensions” folder.
The class that implements this function is called DefaultFunction, derives from the CustomFunction class and must override three methods:
Once this code is compiled into a Java JAR file or .NET assembly DLL, it should be copied into the ‘lib’ folder of the extension and can then be used in the project:
Write a Custom Function Extension
Custom Function Extensions
Example: Create a Custom Function Extension To Capitalize Text