cn.dreampie.common.util.Joiner Maven / Gradle / Ivy
package cn.dreampie.common.util;
import java.io.IOException;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import static cn.dreampie.common.util.Checker.checkNotNull;
/**
* Created by ice on 14-12-29.
*/
public class Joiner {
private final String separator;
private Joiner(String separator) {
this.separator = checkNotNull(separator);
}
private Joiner(Joiner prototype) {
this.separator = prototype.separator;
}
/**
* Returns a joinKit which automatically places {@code separator} between consecutive elements.
*/
public static Joiner on(String separator) {
return new Joiner(separator);
}
/**
* Returns a joinKit which automatically places {@code separator} between consecutive elements.
*/
public static Joiner on(char separator) {
return new Joiner(String.valueOf(separator));
}
private static Iterable