List of utility methods to do Collection Flatten
S | flatten(final S targetCollection, final Collection extends Collection extends T>> setOfSets) flatten for (Collection<? extends T> innerSet : setOfSets) targetCollection.addAll(innerSet); return targetCollection; |
Collection | flattenCollection(Collection col) flatten Collection Collection toRet = null; try { toRet = col.getClass().newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); for (Object o : col) { if (o instanceof Collection) { toRet.addAll(flattenCollection((Collection) o)); } else { toRet.add(o); return toRet; |
String | flattenCollection(Collection> array, String fmt, char separator) Used for flattening a collection of objects into a string StringBuilder builder = new StringBuilder(); for (Object element : array) { String elemValue = null; if (null == element) elemValue = ""; else elemValue = element.toString(); builder.append(String.format(fmt, elemValue, separator)); ... |
Collection | flattenForest(Collection forest) flatten Forest final Collection ret = new LinkedHashSet(); for (final Iterator it = forest.iterator(); it.hasNext();) { final Collection set = (Collection) it.next(); ret.addAll(set); return ret; |
Set | flattenNodeIds(Collection flatten Node Ids Set<Long> nodes = new HashSet<Long>(); synchronized (nodesInMotif) { try { for (Set<Long> motifNodes : nodesInMotif) { nodes.addAll(motifNodes); } catch (ConcurrentModificationException cme) { System.err.println("Error occurred " + cme.getMessage()); ... |
String | flattenStrings(Collection Flatten the list of strings into a single string with a space separator. return flattenStrings(values, " "); |
String | flattenToString(Collection c) Creates a comma separated list of all values held in the given collection. return flattenToString(c, ","); |
String | flattenToString(Collection> collection, String delimiter) flatten To String StringBuffer buffer = new StringBuffer(); for (Object obj : collection) { buffer.append(obj.toString()); buffer.append(','); if (buffer.length() > 0) { buffer.setLength(buffer.length() - 1); return buffer.toString(); |