A set of all the custom functions available in this and all child classes.
Get the keys of the provided object.
The object to get the keys of
Map the provided function over the provided array.
The expression to map over the array
The array to map the expression over
Get the item in the provided array that has the maximum value when the provided expression is evaluated.
The array of items to get the maximum value of
The expression to evaluate for each item in the array
Merge the provided objects into a single object.
Note that this is a shallow merge and will not merge nested objects.
The objects to merge
Get the item in the provided array that has the minimum value when the provided expression is evaluated.
The array of items to get the minimum value of
The expression to evaluate for each item in the array
Sort the provided array by the provided expression.
The array to sort
The expression to sort by
Convert the provided value to a number.
If the provided value is a number, then it is returned. Otherwise, the value is converted to a number and returned.
If the value cannot be converted to a number, then null is returned.
The value to convert to a number
Get the values of the provided object.
The object to get the values of
Lazily introspects the methods of the class instance and all child classes to get the names of the methods that correspond to JMESPath functions.
This method is used to get the names of the custom functions that are available in the class instance and all child classes. The names of the functions are used to create the custom function map that is passed to the JMESPath search function.
The method traverses the inheritance chain going from the leaf class to the root class
and stops when it reaches the Functions
class, which is the root class.
In doing so, it collects the names of the methods that start with func
and adds them
to the methods
set. Finally, when the recursion collects back to the current instance,
it adds the collected methods to the this.methods
set so that they can be accessed later.
Optional
scope: FunctionsThe scope of the class instance to introspect
Static
signatureDecorator to enforce the signature of a function at runtime.
The signature decorator enforces the arity and types of the arguments passed to a function at runtime. If the arguments do not match the expected arity or types errors are thrown.
The options for the signature decorator
A class that contains the built-in JMESPath functions.
The built-in functions are implemented as methods on the Functions class. Each method is decorated with the
@Function.signature()
decorator to enforce the arity and types of the arguments passed to the function at runtime.You can extend the Functions class to add custom functions by creating a new class that extends Functions and adding new methods to it.
Example