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
executemethod 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.Objectthen 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
executemethod:If the execute method returns a basic Java type, the additional method has to return the same basic Java class.
I.e. If the
executemethod returns aStringobject, the additional method has to returnjava.lang.String.class.If the
executemethod returns aCustomRecordValueobject, the additional method has to return aCustomRecordTypeobject.If the execute method returns a
CustomArrayValueobject, the additional method has to return aCustomArrayTypeobject.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.
