List of utility methods to do Collection Element Get
T | getHighest(final Collection extends T> elements, final Comparator Retrieve highest element contained in a collection. return Collections.max(elements, c);
|
Class> | getImplement(Class> aClass, Collection get Implement for (Class<?> c : classCollection) { if (c.isAssignableFrom(aClass)) { return c; return null; |
Object | getIndex(Object collectionOrArray, int index) get Index if (collectionOrArray instanceof Collection) { return getIndex((Collection) collectionOrArray, index); } else if (collectionOrArray.getClass().isArray()) { return ((Object[]) collectionOrArray)[index]; } else { throw new IllegalArgumentException(String.format( "Don't know how to treat object of type '%1$s' as an array", collectionOrArray.getClass())); |
Object | getIndexedValue(Object collection, int index) get Indexed Value Object result = null; if (collection instanceof Object[]) { Object[] x = (Object[]) collection; if (index < x.length) { return x[index]; } else if (collection instanceof Collection) { Collection<?> x = (Collection<?>) collection; ... |