List of utility methods to do Collection Convert
String | toLimitLengthString(final Collection Creates a string representation according to the java.util.AbstractCollection#toString() method, but with a limited length param. if (fallBackToStandardImplementation(coll, limit)) { return coll.toString(); final Iterator<E> iter = coll.iterator(); final StringBuilder sb = new StringBuilder(); sb.append('['); final int min = Math.min(coll.size(), limit); for (int i = 0; i < min; i++) { ... |
List | toLowerCase(Collection to Lower Case List<String> result = new ArrayList<String>(); for (String value : values) result.add(value.toLowerCase()); return result; |
Map | toMap(Collection to Map return toMap(names.toArray(new String[0]), parameters); |
int[][] | toMatrix(Collection to Matrix int[][] result = new int[collection.size()][]; int index = 0; for (int[] array : collection) { result[index++] = array; return result; |
Object[] | toObjectArray(Collection to Object Array Object[] array = new Object[list.size()]; int i = 0; for (Object value : list) array[i++] = value; return array; |
Collection | toObjectCollection(Object v) to Object Collection return (Collection<Object>) v;
|
String | tooDelimitedString(final Collection coll, final String delim, final String prefix, final String suffix) Convenience method to return a Collection as a delimited (e.g. if (coll == null) { return ""; final StringBuilder sb = new StringBuilder(); Iterator it = coll.iterator(); int i = 0; while (it.hasNext()) { if (i > 0) { ... |
double[] | toPrimitiveArray(final Collection Returns a primative array of the passed Collection . double[] results = new double[values.size()]; int index = 0; Iterator<Double> iter = values.iterator(); while (iter.hasNext()) { Double value = iter.next(); if (value != null) { results[index] = value; index++; ... |
int[] | toPrimitiveIntegerArray(Collection to Primitive Integer Array int[] result = new int[collection.size()]; int i = 0; for (Integer n : collection) { result[i++] = n; return result; |
String | toReadableString(Collection collection) to Readable String Iterator it = collection.iterator(); StringBuilder strb = new StringBuilder(); while (it.hasNext()) { Object next = it.next(); strb.append(next.toString() + ", "); if (strb.length() > 2) { strb.delete(strb.length() - 2, strb.length()); ... |