List of utility methods to do Iterable
StringBuilder | appendTo(StringBuilder appendable, Iterable> parts, CharSequence separator) append To Iterator<?> iterator = parts.iterator(); if (iterator.hasNext()) { appendable.append(toString(iterator.next())); while (iterator.hasNext()) { appendable.append(separator); appendable.append(toString(iterator.next())); return appendable; |
void | commafy(Iterable col, StringBuilder builder) commafy for (Iterator itr = col.iterator(); itr.hasNext();) { Object obj = itr.next(); builder.append(obj.toString()); if (itr.hasNext()) { builder.append(", "); |
boolean | containsSame(Iterable> coll, Object obj) contains Same for (Iterator<?> iterator = coll.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element == obj) return true; return false; |
Iterable | convertIterable(final Iterable extends Iterable> iterables) convert Iterable final List<Iterator<U>> iterators = new LinkedList<>(); for (Iterable<U> i : iterables) { iterators.add(i.iterator()); return iterators; |
String | createDelimitedString(Iterable iterable, String delimiter) create Delimited String Iterator iter = iterable.iterator(); String string = ""; while (iter.hasNext()) { string += iter.next(); if (iter.hasNext()) string += delimiter; return string; ... |
String | createUpdateTemplate(String table, Iterable A static helper method for generating SQL templates for UPDATE statements for the provided column colection or array StringBuilder builder = new StringBuilder(); builder.append("update ").append(table).append(" set "); Iterator<String> it = columns.iterator(); while (it.hasNext()) { builder.append(it.next()).append(" = ?"); if (it.hasNext()) builder.append(", "); return builder.append(" ").toString(); |
boolean | equal(Iterable it1, Iterable it2) equal Iterator i1 = it1.iterator();
Iterator i2 = it2.iterator();
return equal(i1, i2);
|
boolean | equalsIterablesInOrder(Iterable> i1, Iterable> i2) Check if values in iterables are identical and in identical order If both are instanceof Collection, this method check sizes first Calls only once Itarable#iterator() for both iterables if (i1 == i2) { return true; if (i1 == null) { if (i2 == null) { return true; return false; ... |
C | fillFromIterable(C c, Iterable Adds all of the items from a given Iterable into a Collection . return fillFromIterator(c, i.iterator());
|
T | getAny(Iterable Returns one object from an Iterable or null if the iterable is empty.
Iterator<T> iterator = iterable.iterator(); if (!iterator.hasNext()) { return null; return iterator.next(); |