List of utility methods to do Collection Create
Collection | toCollection(final T[] elements) Create a collection using an array. final List<T> result = new ArrayList<T>(); for (T element : elements) { result.add(element); return result; |
Collection | toCollection(Iterable to Collection List<E> collection = new ArrayList<E>(); iterable.forEach(e -> collection.add(e)); return collection; |
Collection | toCollection(Iterable Convert an Iterable to a Collection (ArrayList under the hood). if (i == null) { throw new IllegalArgumentException("Iterable 'i' cannot be null"); Collection<T> c = new ArrayList<T>(); for (T t : i) { c.add(t); return c; ... |
Collection | toCollection(Object o) to Collection if (o == null) { return Collections.emptyList(); } else { return Collections.singletonList(o); |
Collection | toCollection(String value) to Collection if (value == null) { throw new IllegalArgumentException("Cannot add null value to collection."); Collection<String> collection = new ArrayList<String>(); collection.add(value); return collection; |