List of utility methods to do List from Array
List | arrayToListWithUpperCase(String[] arrValues) Convenience method to return a String array as a CSV String. List values = null; if (arrValues != null) { values = new ArrayList(); int size = arrValues.length; for (int i = 0; i < size; i++) { values.add(arrValues[i] != null ? arrValues[i].toUpperCase() : null); return values; |
String | arrayToString(List arr) array To String if (arr == null || arr.isEmpty()) { return ""; StringBuilder buf = new StringBuilder(); arr.stream().forEach((str) -> { if (buf.length() > 0) { buf.append(", "); buf.append(str); }); return buf.toString(); |
List | arrayToStringList(Object array) array To String List if (array == null) return null; if (!array.getClass().isArray()) return null; Class<?> componentType = array.getClass().getComponentType(); if (componentType == null) return null; if (String.class.isAssignableFrom(componentType)) { ... |
List | asList() as List return new ArrayList<T>(); |
List | asList(boolean[] array) as List return new AbstractList<Boolean>() { @Override public int size() { return array.length; @Override public Boolean get(int index) { return array[index]; ... |
List | asList(byte[] array) as List return asList(array, 0, array.length);
|
List | asList(Class>... classesArray) as List List<Class<?>> classes = new ArrayList<Class<?>>(); for (Class<?> clazz : classesArray) { classes.add(clazz); return classes; |
List | asList(Collection collection) as List List<E> result = new ArrayList<E>(); for (Object obj : collection) { result.add((E) obj); return result; |
List | asList(Collection> collection, Class Convert the collection to a typed list of given type. List<T> list = new ArrayList<T>(); for (Object o : collection) { if (type.isInstance(o)) { list.add(type.cast(o)); return list; |
ArrayList | asList(Collection Creates a new ArrayList from a collection by building an enumeration over the collection. return Collections.list(Collections.<K>enumeration(values));
|