Skip to content

Implementing your own functions

Esta Nagy edited this page Jul 1, 2020 · 3 revisions

Functions are providing endless possibilities. You are at the right place if you want to get the most out of them.

To implement a new function, you need to take only a couple of simple steps. Please find them below:

  1. Create a class for your function implementing the Function interface
  2. Create a constructor using only the supported parameter types as parameters
  3. Annotate your constructor with @NamedFunction
  4. Annotate all of your constructor parameters as defined here
  5. Implement the apply(T) method coming form the interface.
  6. Register your function using FunctionRegistry#registerFunctionClass(Class)
  7. Make sure to add your function to the #/definitions/functionTypes/definitions node of our JSON Schema
    1. Add a new definition similarly to the examples already in there
    2. Register the type function to the definition of the anyFunction definition by
      1. Adding the name to the enum containing all the names
      2. Adding a new object to the list similar to this:
          {
            "if": {
              "properties": {
                "name": {
                  "const": "stringDateAdd"
                }
              }
            },
            "then": {
              "$ref": "#/definitions/functionTypes/definitions/functionStringDateAdd"
            }
          }
  8. Profit!