Java Utililty Methods Iterable

List of utility methods to do Iterable

Description

The list of methods to do Iterable are organized into topic(s).

Method

StringBuilderappendTo(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;
voidcommafy(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(", ");
booleancontainsSame(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> iterables)
convert Iterable
final List<Iterator<U>> iterators = new LinkedList<>();
for (Iterable<U> i : iterables) {
    iterators.add(i.iterator());
return iterators;
StringcreateDelimitedString(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;
...
StringcreateUpdateTemplate(String table, Iterable columns)
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();
booleanequal(Iterable it1, Iterable it2)
equal
Iterator i1 = it1.iterator();
Iterator i2 = it2.iterator();
return equal(i1, i2);
booleanequalsIterablesInOrder(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;
...
CfillFromIterable(C c, Iterable i)
Adds all of the items from a given Iterable into a Collection .
return fillFromIterator(c, i.iterator());
TgetAny(Iterable 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();