/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<>(convertArrayToArrayList(array)); } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<Object>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<Object>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<Object>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<Object>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<Object>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<Object>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }