docs: static void encode(Environment environment, LocalFunctionRegistry registry, Class returnType, Object result, OutputStream output) throws IOException {
          if (ClassUtils.isJavaLangType(returnType)) {
              if (result instanceof Byte) {
                  output.write((Byte) result);
              } else if (result instanceof Boolean) {
                  output.write(((Boolean) result) ? 1 : 0);
              } else if (result instanceof byte[]) {
                  output.write((byte[]) result);
              } else {
                  byte[] bytes = environment
                      .convert(result.toString(), byte[].class)
                      .orElseThrow(() -> new InvocationException("Unable to convert result [" + result + "] for output stream"));
                  output.write(bytes);
              }
          }