List of utility methods to do Collection Element Get
String | getCollectionClosingSymbol(Collection> col) get Collection Closing Symbol if (col instanceof List) { return "]"; if (col instanceof Set) { return "}"; return ")"; |
String | getCollectionPreview(final Collection> collection, int previewSize) Generates a string that enumerates just the first elements of a collection (a preview). final Iterator<?> it = collection.iterator(); final StringBuilder buffer = new StringBuilder(); if (it.hasNext()) { buffer.append('[').append(it.next().toString()); for (; previewSize > 0 && it.hasNext(); --previewSize) buffer.append(LIST_SEPARATOR).append(' ').append(it.next().toString()); if (it.hasNext()) buffer.append(" ... "); ... |
int | getCollectionSize(Collection collection) return collection size return collection != null ? collection.size() : 0;
|
int | getCollectionSize(Collection> collection) Returns size of the incoming list if (collection == null) return 0; else return collection.size(); |
String | getCommaDelimitedString(Collection> elements) Transforms a collection of Integers into a comma delimited String. final StringBuilder builder = new StringBuilder(); if (elements != null && !elements.isEmpty()) { for (Object element : elements) { builder.append(element.toString()).append(DELIMITER); return builder.substring(0, builder.length() - DELIMITER.length()); return builder.toString(); ... |
String | getCommaSeparatedString(Collection extends Object> collection) get Comma Separated String StringBuffer buffer = new StringBuffer(); Iterator<? extends Object> iterator = collection.iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); buffer.append(obj.toString()); if (iterator.hasNext()) { buffer.append(", "); return buffer.toString(); |
String | getCommaSeparatedString(Collection get Comma Separated String if (values == null || values.size() == 0) { return null; StringBuilder builder = new StringBuilder(); for (String value : values) { builder.append(value); builder.append(COMMA); return builder.substring(0, builder.length() - 1); |
String | getCommaSeparatedStringFromCollection(Collection get Comma Separated String From Collection StringBuilder result = new StringBuilder(); if (collections != null) { Object[] array = collections.toArray(); for (int i = 0; i < array.length; i++) { result.append(array[i]); if (i < array.length - 1) { result.append(','); return result.toString(); |
Collection | getCommon(Collection c1, Collection c2) get Common objects between two collections Iterator iterator = c1.iterator(); while (iterator.hasNext()) { Object o1 = iterator.next(); if (!c2.contains(o1)) iterator.remove(); return c1; |
List | getCommonElements(Collection get Common Elements List<E> res = new ArrayList<E>(); for (E f : from) { for (E t : to) { if (f.equals(t)) { res.add(f); return res; |