List of utility methods to do Collection First
Object | first(Collection collection) first Object[] obj = collection.toArray(); if (obj.length > 0) { return obj[0]; } else { return null; |
T | first(Collection collection) first if (size(collection) > 0) { return (T) collection.iterator().next(); return null; |
Object | first(Collection items) Null safe access to the first object in a collection if (items != null && items.size() > 0) { return items.iterator().next(); return null; |
E | first(Collection extends E> collection, E alternative) first Iterator<? extends E> iterator = collection.iterator(); if (iterator.hasNext()) { return iterator.next(); return alternative; |
T | first(Collection extends T> collection) first ArrayList<T> list = new ArrayList<>(collection); return list.isEmpty() ? null : list.get(0); |
T | first(Collection extends T> collection) first final T notFound = null; return isEmpty(collection) ? notFound : collection.iterator().next(); |
Double | first(Collection first List<Double> filteredValues = filterNulls(values);
return filteredValues.size() > 0 ? filteredValues.get(0) : null;
|
E | first(Collection first if (isEmpty(collection)) { return null; Iterator<E> iterator = collection.iterator(); if (iterator.hasNext()) { return iterator.next(); throw new IllegalStateException("Should not happen"); ... |
E | first(Collection Implementation of the OCL
if (self.isEmpty()) { return null; return self.iterator().next(); |
T | first(Collection first return c.iterator().next();
|