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

StringtoFriendlyString(Iterable iterable, String seperator)
Turns every element of the iterable into a friendly string which can be used in a statement
Iterator<?> iter = iterable.iterator();
StringBuilder builder = new StringBuilder();
while (iter.hasNext()) {
    Object next = iter.next();
    builder.append(next);
    if (iter.hasNext())
        builder.append(seperator);
return builder.toString();
Tunique(Iterable source, T defaultElement)
Gets either the only element or the default one.
T element = defaultElement;
if (source != null) {
    Iterator<T> i = source.iterator();
    if (i.hasNext()) {
        element = i.next();
        if (i.hasNext()) {
            throw new IllegalStateException("Element not unique!");
return element;
Iterator[]valueOfMultiple(Iterable... iterables)
Returns a List of the Iterator s related to the given Iterable s
List<Iterator<E>> retlist = new ArrayList<Iterator<E>>();
if (iterables != null) {
    for (Iterable<E> iterable : iterables) {
        if (iterable != null) {
            Iterator<E> iterator = iterable.iterator();
            if (iterator != null) {
                retlist.add(iterator);
return retlist.toArray(new Iterator[0]);