Class ArrayUtils
- java.lang.Object
-
- com.api.jsonata4java.expressions.utils.ArrayUtils
-
- All Implemented Interfaces:
Serializable
public class ArrayUtils extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArrayUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancompare(com.fasterxml.jackson.databind.JsonNode left, com.fasterxml.jackson.databind.JsonNode right)Default comparison function for $sortstatic com.fasterxml.jackson.databind.node.ArrayNodeensureArray(com.fasterxml.jackson.databind.JsonNode n)If n is an array, it will be returned untouched.static booleanisArrayOfNumbers(com.fasterxml.jackson.databind.JsonNode arr)Determines if the supplied array contains all numeric valuesstatic booleanisArrayOfStrings(com.fasterxml.jackson.databind.JsonNode arr)Determines if the supplied array contains all String valuesstatic com.fasterxml.jackson.databind.node.ArrayNodepush(com.fasterxml.jackson.databind.node.ArrayNode left, com.fasterxml.jackson.databind.JsonNode right)Merges the left, then the right array into the resulting array, preserving the element's orderstatic com.fasterxml.jackson.databind.node.ArrayNodeslice(com.fasterxml.jackson.databind.node.ArrayNode array, int start)Returns a shallow copy of the portion of the supplied array from start through the end of the arraystatic com.fasterxml.jackson.databind.node.ArrayNodeslice(com.fasterxml.jackson.databind.node.ArrayNode array, int start, int end)Returns a shallow copy of the portion of the supplied array from start to end (not including end)
-
-
-
Method Detail
-
isArrayOfNumbers
public static boolean isArrayOfNumbers(com.fasterxml.jackson.databind.JsonNode arr)
Determines if the supplied array contains all numeric values- Parameters:
arr- the array to be evaluated.- Returns:
- true if the supplied array contains all numeric values. If arr is not an array, returns false.
-
isArrayOfStrings
public static boolean isArrayOfStrings(com.fasterxml.jackson.databind.JsonNode arr)
Determines if the supplied array contains all String values- Parameters:
arr- the array to be evaluated.- Returns:
- true if the supplied array contains all String values. If arr is not an array, returns false.
-
compare
public static boolean compare(com.fasterxml.jackson.databind.JsonNode left, com.fasterxml.jackson.databind.JsonNode right) throws EvaluateRuntimeExceptionDefault comparison function for $sort- Parameters:
left- string or number to be comparedright- string or number to be compared- Returns:
- true is left is greater than right
- Throws:
EvaluateRuntimeException- if left and right cannot be converted to numbers
-
ensureArray
public static com.fasterxml.jackson.databind.node.ArrayNode ensureArray(com.fasterxml.jackson.databind.JsonNode n)
If n is an array, it will be returned untouched. Otherwise, return a singleton array containing the value- Parameters:
n- JsonNode being checked- Returns:
- corresponding array made from the input n
-
push
public static com.fasterxml.jackson.databind.node.ArrayNode push(com.fasterxml.jackson.databind.node.ArrayNode left, com.fasterxml.jackson.databind.JsonNode right)Merges the left, then the right array into the resulting array, preserving the element's order- Parameters:
left- first array to be mergedright- second array to be merged- Returns:
- merged array containing the elements of left then the elements of right
-
slice
public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start, int end)Returns a shallow copy of the portion of the supplied array from start to end (not including end)- Parameters:
array-start-end-- Returns:
- a shallow copy of the portion of the supplied array from start to end (not including end)
-
slice
public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start)Returns a shallow copy of the portion of the supplied array from start through the end of the array- Parameters:
array- input array to be slicedstart- starting index where the slice should occur- Returns:
- a shallow copy of the portion of the supplied array from start through the end of the array
-
-