Class ArrayUtils

    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean compare​(com.fasterxml.jackson.databind.JsonNode left, com.fasterxml.jackson.databind.JsonNode right)
      Default comparison function for $sort
      static com.fasterxml.jackson.databind.node.ArrayNode ensureArray​(com.fasterxml.jackson.databind.JsonNode n)
      If n is an array, it will be returned untouched.
      static boolean isArrayOfNumbers​(com.fasterxml.jackson.databind.JsonNode arr)
      Determines if the supplied array contains all numeric values
      static boolean isArrayOfStrings​(com.fasterxml.jackson.databind.JsonNode arr)
      Determines if the supplied array contains all String values
      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
      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
      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)
    • Constructor Detail

      • ArrayUtils

        public ArrayUtils()
    • 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 EvaluateRuntimeException
        Default comparison function for $sort
        Parameters:
        left - string or number to be compared
        right - string or number to be compared
        Returns:
        true is left is greater than right
        Throws:
        EvaluateRuntimeException - if left and right can not 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 merged
        right - 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 sliced
        start - 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