CollectionUtils { public static List<Object> convertPrimitiveArrayToList(Object primitiveArray) { int length = Array.getLength(primitiveArray); List<Object> result = new ArrayList<>(length); for (int i = 0; i < length; i++) { result.add(Array.get(primitiveArray, i)); } return result; } private  CollectionUtils(); static boolean isArray(Class<?> aClass); static boolean isCollection(Class<?> aClass); static boolean isList(Class<?> aClass); static boolean isSet(Class<?> aClass); static boolean isPrimitiveArray(Class<?> aClass); static int getLengthOfCollection(Object value); static Object getValueFromCollection(Object collection, int index); static Set<?> createNewSet(Class<T> destType); static Set<?> createNewSet(Class<T> destSetType, Collection<?> srcValue); static Object convertListToArray(List<T> list, Class<T> destEntryType); static List<Object> convertPrimitiveArrayToList(Object primitiveArray); static Set<E> intersection(final Set<E> set1, final Set<?> set2);  }
@Test public void testConvertPrimitiveArrayToList() { int[] srcArray = new int[] {5, 10, 15}; List<?> result = CollectionUtils.convertPrimitiveArrayToList(srcArray); assertEquals("invalid result size", srcArray.length, result.size()); for (int i = 0; i < srcArray.length; i++) { Integer srcValue = new Integer(srcArray[i]); Integer resultValue = (Integer)result.get(i); assertEquals("invalid result entry value", srcValue, resultValue); } }