Package com.graphaware.common.util
Class ArrayUtils
- java.lang.Object
-
- com.graphaware.common.util.ArrayUtils
-
public final class ArrayUtils extends Object
Static utility methods for dealing with arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
arrayFriendlyEquals(Object o1, Object o2)
Check whether two objects, potentially arrays, are equal.static int
arrayFriendlyHashCode(Object o)
Get has code of the object, which could be an arrays.static <T> boolean
arrayFriendlyMapEquals(Map<String,T> map1, Map<String,T> map2)
Check equality of both maps that can have arrays as values.static boolean
isArray(Object o)
Check if the given object is an array.static boolean
isPrimitiveArray(Object o)
Check if the given object is a primitive array.static boolean
isPrimitiveOrStringArray(Object o)
Check if the given object is a primitive array or an array of Strings.static String
primitiveOrStringArrayToString(Object o)
Convert a primitive array or an array of Strings to string.
-
-
-
Method Detail
-
isPrimitiveArray
public static boolean isPrimitiveArray(Object o)
Check if the given object is a primitive array.- Parameters:
o
- to check.- Returns:
- true iff o is a primitive array.
-
isPrimitiveOrStringArray
public static boolean isPrimitiveOrStringArray(Object o)
Check if the given object is a primitive array or an array of Strings.- Parameters:
o
- to check.- Returns:
- true iff o is a primitive array or an array of Strings.
-
isArray
public static boolean isArray(Object o)
Check if the given object is an array.- Parameters:
o
- to check.- Returns:
- true iff o is an array.
-
arrayFriendlyEquals
public static boolean arrayFriendlyEquals(Object o1, Object o2)
Check whether two objects, potentially arrays, are equal.- Parameters:
o1
- object 1o2
- object 2- Returns:
- true iff o1 and o2 are equal.
-
arrayFriendlyHashCode
public static int arrayFriendlyHashCode(Object o)
Get has code of the object, which could be an arrays. Hash codes of arrays that are equal according toarrayFriendlyEquals(Object, Object)
are the same.- Parameters:
o
- to get a hash code for.- Returns:
- hash code.
-
primitiveOrStringArrayToString
public static String primitiveOrStringArrayToString(Object o)
Convert a primitive array or an array of Strings to string.- Parameters:
o
- to convert.- Returns:
- as string.
- Throws:
IllegalArgumentException
- if o isn't a primitive array or an array of Strings.
-
-