
package de.ivu.elect.util;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by  on 29.06.2018.
 */
public class StringJoiner {

  public static final String DELIMITER = ", ";
  public static final String BLANK = " ";

  public static String joinWithComma(String... strings) {
    return joinWithComma(Arrays.asList(strings));
  }

  public static String joinWithComma(List<String> strings) {
    return joinWithCustomSeparator(DELIMITER, strings);
  }

  public static String joinWithBlanks(String... strings) {
    return joinWithBlanks(Arrays.asList(strings));
  }

  public static String joinWithBlanks(List<String> strings) {
    return joinWithCustomSeparator(BLANK, strings);
  }

  public static String joinWithCustomSeparator(String separator, String... strings) {
    return joinWithCustomSeparator(separator, Arrays.asList(strings));
  }

  public static String joinWithCustomSeparator(String separator, List<String> strings) {
    return strings.stream().filter(StringUtils::isNotBlank).collect(Collectors.joining(separator));
  }
}
