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

org.xbib.net.security.signatures.Joiner Maven / Gradle / Ivy

The newest version!
package org.xbib.net.security.signatures;

import java.util.Collection;

public class Joiner {

    private Joiner() {
    }

    public static String join(final String delimiter, final Collection collection) {
        if (collection.size() == 0) {
            return "";
        }
        final StringBuilder sb = new StringBuilder();
        for (final Object obj : collection) {
            sb.append(obj).append(delimiter);
        }
        return sb.substring(0, sb.length() - delimiter.length());
    }

    public static String join(final String delimiter, final Object... collection) {
        if (collection.length == 0) {
            return "";
        }
        final StringBuilder sb = new StringBuilder();
        for (final Object obj : collection) {
            sb.append(obj).append(delimiter);
        }
        return sb.substring(0, sb.length() - delimiter.length());
    }
}