java.lang.Object
org.sentrysoftware.metricshub.engine.common.helpers.ArrayHelper

public class ArrayHelper extends Object
Utility class for handling arrays and common array-related operations.
  • Method Details

    • getValueAtIndex

      public static <T> T getValueAtIndex(T[] array, int index, T defaultValue)
      Returns the element at the specified position in the array.
      Type Parameters:
      T - The type of elements in the array.
      Parameters:
      array - The array from which to retrieve the element.
      index - Index of the element to return.
      defaultValue - The default value to return if the element cannot be extracted.
      Returns:
      The element at the specified position, or the default value if not present.
    • anyMatchLowerCase

      public static boolean anyMatchLowerCase(Predicate<String> predicate, String... data)
      Check if the given data matches using the predicate function.
      Each data element is converted to lower case before applying the predicate.
      Parameters:
      predicate - boolean-valued function to check the passed data
      data - the input to the predicate
      Returns:
      true if one of the data matched otherwise false
    • hexToByteArray

      public static byte[] hexToByteArray(String hexString)
      Convert the specified hexadecimal string into a byte array.
      Example:
      "0x010203" => new byte[] { 0x01, 0x02, 0x03 }
      Parameters:
      hexString - Hexadecimal string (may be prefixed with "0x" or "#")
      Returns:
      the corresponding byte array