List of utility methods to do Collection Convert
String | toDelimitedString(final Collection coll, final String delim) Convenience method to return a Collection as a delimited (e.g. return tooDelimitedString(coll, delim, "", ""); |
List | toDoubles(Collection extends Number> numbers) to Doubles List<Double> result = new ArrayList<Double>(); for (Number number : numbers) { result.add(number.doubleValue()); return result; |
Enumeration | toEnumeration(final Collection to Enumeration return Collections.enumeration(collection);
|
String | toEscapedStringWithDelimiters(Collection objects, String delim) to Escaped String With Delimiters StringBuffer buffer = new StringBuffer(); int index = 0; for (Object obj : objects) { if (index++ > 0) buffer.append(delim); String string = obj.toString(); if (string.startsWith("\"") && string.endsWith("\"")) { if (string.length() <= 2) ... |
boolean | toggleEntry(T entry, Collection Toggles an entry in a collection. if (collection.remove(entry)) { return false; } else { collection.add(entry); return true; |
Set | toHashSet(Collection to Hash Set if (isEmpty(c)) { return null; Set<T> set = new HashSet<T>(c.size() * 2); set.addAll(c); return set; |
String | toHtml(Collection collection) to Html StringBuffer sb = new StringBuffer(); sb.append("<ul>"); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { sb.append("<li>"); sb.append(iterator.next()); sb.append("</li>"); sb.append("</ul>"); return sb.toString(); |
Collection | toIntegerCollection(int[] ints) to Integer Collection ArrayList<Integer> ret = new ArrayList<Integer>(); for (int i : ints) ret.add(new Integer(i)); return ret; |
String | toJSONString(Collection collection) to JSON String if (collection == null) { return null; } else { StringBuilder sb = new StringBuilder(); sb.append('['); for (Object item : collection) { if (item == null) { sb.append("null"); ... |
String | tokenSetString(Collection token Set String String string = String.join(", ", addNewLines(tokens)); if (tokens.size() < 5) { return string; } else { return "\n" + string + "\n"; |