Custom Function Return Type¶
As explained before, custom functions which return type depends on input values or functions returning compound types can implement an additional method in order to compute the return type without executing the function. This is entirely optional, but it provides better performance when the execution of the function is slower or more memory intensive than the return type calculation.
This additional method must follow a few rules:
When the
execute
method returns a non-constant compound type (a record whose fields -number of fields, and their names and/or types- depend on the input parameters) or ajava.lang.Object
then the additional method must be implemented. In other situations it is optional (the return type is obtained from the method directly).The execution method must have the same number of parameters as the additional method.
Each parameter of the additional method must have the same or equivalent type, as its respective parameter in the
execute
method:If the execute method returns a basic Java type, the additional method has to return the same basic Java class.
I.e. If the
execute
method returns aString
object, the additional method has to returnjava.lang.String.class
.If the
execute
method returns aCustomRecordValue
object, the additional method has to return aCustomRecordType
object.If the execute method returns a
CustomArrayValue
object, the additional method has to return aCustomArrayType
object.See table Equivalency between Java and ITPilot data types at the beginning of section Creating Custom ITPilot Functions to know the type that these return parameters will have in ITPilot.