Interface Function

All Known Implementing Classes:
Function.ArgDrivenFunction, Function.ArgDrivenListFunction, Function.ArgDrivenSingleFunction, Function.BaseFunction, Function.ListFunction, Function.SingleFunction, Function.SquashFunction, Lists.elementAt, Lists.firstElement, Lists.lastElement, Lists.sort, Lists.toList, Math.abs, Math.avg, Math.divide, Math.divideAndRound, Math.doubleSubtract, Math.doubleSum, Math.intSubtract, Math.intSum, Math.longSubtract, Math.longSum, Math.max, Math.min, Objects.recursivelySquashNulls, Objects.size, Objects.squashNulls, Objects.toBoolean, Objects.toDouble, Objects.toInteger, Objects.toLong, Objects.toString, Strings.concat, Strings.join, Strings.leftPad, Strings.rightPad, Strings.split, Strings.substring, Strings.toLowerCase, Strings.toUpperCase, Strings.trim

@Deprecated public interface Function
Deprecated.
Modifier supports a Function on RHS that accepts jolt path expressions as arguments and evaluates them at runtime before calling it. Function always returns an Optional, and the value is written only if the optional is not empty. function spec is defined by "key": "=functionName(args...)" input: { "num": -1.0 } spec: { "num": "=abs(@(1,invalid input: '&'0))" } will call the stock function Math.abs() and will pass the matching value at "num" spec: { "num": "=abs" } an alternative shortcut will do the same thing output: { "num": 1.0 } input: { "value": -1.0 } spec: { "absValue": "=abs(@(1,value))" } will evaluate the jolt path expression @(1,value) and pass the output to stock function Math.abs() output: { "value": -1.0, "absValue": 1.0 } Currently defined stock functions are: toLower - returns toLower value of toString() value of first arg, rest is ignored toUpper - returns toUpper value of toString() value of first arg, rest is ignored concat - concatenate all given arguments' toString() values min - returns the min of all numbers provided in the arguments, non-numbers are ignored max - returns the max of all numbers provided in the arguments, non-numbers are ignored abs - returns the absolute value of first argument, rest is ignored toInteger - returns the intValue() value of first argument if its numeric, rest is ignored toDouble - returns the doubleValue() value of first argument if its numeric, rest is ignored toLong - returns the longValue() value of first argument if its numeric, rest is ignored All of these functions returns Optional.EMPTY if unsuccessful, which results in a no-op when performing the actual write in the json doc. i.e. input: { "value1": "xyz" } --- note: string, not number { "value1": "1.0" } --- note: string, not number spec: { "value1": "=abs" } --- fails silently { "value2": "=abs" } output: { "value1": "xyz", "value2": "1" } --- note: "absValue": null is not inserted This is work in progress, and probably will be changed in future releases. Hence it is marked for removal as it'll eventually be moved to a different package as the Function feature is baked into other transforms as well. In short this interface is not yet ready to be implemented outside jolt!
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Deprecated.
    Abstract class that provides rudimentary abstraction to quickly implement a function that classifies first arg as special input and rest as regular input.
    static class 
    Deprecated.
    Extends ArgDrivenConverter to provide rudimentary abstraction to quickly implement a function that works on an input list|array i.e.
    static class 
    Deprecated.
    Extends ArgDrivenConverter to provide rudimentary abstraction to quickly implement a function that works on a single input i.e.
    static class 
    Deprecated.
    Abstract class that processes var-args and calls two abstract methods If its single list arg, or many args, calls applyList() else calls applySingle()
    static class 
    Deprecated.
    Abstract class that provides rudimentary abstraction to quickly implement a function that works on an List of input i.e.
    static class 
    Deprecated.
    Abstract class that provides rudimentary abstraction to quickly implement a function that works on an single value input i.e.
    static class 
    Deprecated.
    squashNull is a special kind of null processing,the input is always a list or map as a singleton
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Function
    Deprecated.
    Returns the first argument if it is null spec - "key": ["=inNull", "otherValue" ] input - "key": null output - "key": null input - "key": "value" output - "key": "otherValue"
    static final Function
    Deprecated.
    Returns the first argument, null or otherwise spec - "key": [ "=isPresent", "otherValue" ] input - "key": null output - "key": null input - "key": "value" output - "key": "value" input - key is missing output - "key": "otherValue"
    static final Function
    Deprecated.
    Does nothing spec - "key": "=noop" will cause the key to remain unchanged
    static final Function
    Deprecated.
    Returns the first argument if in not null spec - "key": ["=notNull", "otherValue" ] input - "key": null output - "key": "otherValue" input - "key": "value" output - "key": "value"
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(Object... args)
    Deprecated.
     
  • Field Details

    • noop

      static final Function noop
      Deprecated.
      Does nothing spec - "key": "=noop" will cause the key to remain unchanged
    • isPresent

      static final Function isPresent
      Deprecated.
      Returns the first argument, null or otherwise spec - "key": [ "=isPresent", "otherValue" ] input - "key": null output - "key": null input - "key": "value" output - "key": "value" input - key is missing output - "key": "otherValue"
    • notNull

      static final Function notNull
      Deprecated.
      Returns the first argument if in not null spec - "key": ["=notNull", "otherValue" ] input - "key": null output - "key": "otherValue" input - "key": "value" output - "key": "value"
    • isNull

      static final Function isNull
      Deprecated.
      Returns the first argument if it is null spec - "key": ["=inNull", "otherValue" ] input - "key": null output - "key": null input - "key": "value" output - "key": "otherValue"
  • Method Details