Class ArrayHelper
java.lang.Object
org.sentrysoftware.metricshub.engine.common.helpers.ArrayHelper
Utility class for handling arrays and common array-related operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleananyMatchLowerCase(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.static <T> TgetValueAtIndex(T[] array, int index, T defaultValue) Returns the element at the specified position in the array.static byte[]hexToByteArray(String hexString) Convert the specified hexadecimal string into a byte array.
-
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
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 datadata- the input to the predicate- Returns:
trueif one of the data matched otherwisefalse
-
hexToByteArray
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
-