List of utility methods to do Collection Search
T | getSingle(Collection get Single if (configs.size() == 1) { for (T t : configs) { return t; return null; |
T | getSingleElement(Collection get Single Element isEmptyException(collection);
return collection.iterator().next();
|
T | getSingleElement(Collection Returns the single element contained by the input collection if (collection.size() != 1) throw new IndexOutOfBoundsException( String.format("Expected collection to contain a single element, but observed %d elements: %s", collection.size(), collection.toString())); return collection.iterator().next(); |
T | getSingleItem(Collection get Single Item assert values.size() == 1; if (values instanceof List) { return ((List<T>) values).get(0); } else { return (T) values.toArray()[0]; |
R | getSingleValue(Iterable get Single Value return getSingleValue(collection, "Single value expected"); |
boolean | hasElements(Collection> c) has Elements return !isEmpty(c);
|
boolean | hasElements(Collection> c) has Elements return c != null && !c.isEmpty();
|
boolean | hasElements(Collection Checks whether the COLLECTION is not NULL and has at least one element. return (null != collection && collection.size() > 0);
|
boolean | hasElements(Collection has Elements return (t != null) && (t.size() > 0);
|
int | hashCapacityFor(Collection> collection) hash Capacity For return (int) Math.ceil(collection.size() / 0.75); |