List of utility methods to do Collection Create
String | createTextFromList(Collection create Text From List if (list.isEmpty()) return ""; StringBuilder htmlList = new StringBuilder(); for (String listItem : list) { htmlList.append("* ").append(listItem); htmlList.append("\n"); htmlList.deleteCharAt(htmlList.length() - 1); ... |
String | createUniqueName(String baseName, Collection Generate a unique name based on the given name and the name of already existing elements. String uniqueName = baseName; int idx = -1; for (String name : names) { if (!name.startsWith(baseName)) { continue; String suffix = name.substring(baseName.length()); if (suffix.isEmpty()) { ... |
Collection | stringToCollection(String string) Returns a comma-delimitted list of Strings as a Collection. if (string == null || string.trim().length() == 0) { return Collections.emptyList(); Collection<String> collection = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(string, ","); while (tokens.hasMoreTokens()) { collection.add(tokens.nextToken().trim()); return collection; |
Collection | stringToCollection(String string) Returns a comma-delimitted list of Strings as a Collection. if (string == null || string.trim().length() == 0) { return Collections.emptyList(); Collection<String> collection = new ArrayList<>(); StringTokenizer tokens = new StringTokenizer(string, ","); while (tokens.hasMoreTokens()) { collection.add(tokens.nextToken().trim()); return collection; |
ArrayList | stringToCollection(String string, String delim) This method will return all the values in a delimited String as a Collection of String objects. return stringToCollection(string, delim, false);
|
C | toCollection(C c, E... elements) to Collection if (elements != null) { for (E element : elements) { c.add(element); return c; |
C | toCollection(Class to Collection try { C result = cls.newInstance(); for (T item : iterable) { result.add(item); return result; } catch (InstantiationException ex) { return null; ... |
Collection | toCollection(Class to Collection try { Collection<T> collection = cls.newInstance(); for (T t : array) { collection.add(t); return collection; } catch (RuntimeException re) { throw re; ... |
Collection extends String> | toCollection(final char[] charArray) to Collection final Collection<String> c = new ArrayList<String>(); for (final Object obj : charArray) { c.add(obj.toString()); return c; |
Collection | toCollection(final Iterable Converts an Iterable into a Collection .
final Collection<E> col = new ArrayList<E>(); final Iterator<E> it = iterable.iterator(); while (it.hasNext()) { final E item = it.next(); col.add(item); return col; |