All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jparams.junit4.util.Joiner Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package com.jparams.junit4.util;

import java.util.Arrays;
import java.util.Iterator;

public class Joiner {
    private Joiner() {
    }

    public static String join(Iterable objects, String separator) {
        StringBuilder builder = new StringBuilder();

        Iterator iterator = objects.iterator();

        while (iterator.hasNext()) {
            builder.append(iterator.next());

            if (iterator.hasNext()) {
                builder.append(separator);
            }
        }

        return builder.toString();
    }

    public static String join(Object[] objects, String separator) {
        return join(Arrays.asList(objects), separator);
    }
}