gherkin.StringUtils Maven / Gradle / Ivy
The newest version!
package gherkin;
import java.util.List;
public class StringUtils {
public static String join(String separator, List items) {
return join(ToString.DEFAULT, separator, items);
}
public static String join(ToString toString, String separator, Iterable items) {
StringBuilder sb = new StringBuilder();
boolean useSeparator = false;
for (T item : items) {
if (useSeparator) sb.append(separator);
useSeparator = true;
sb.append(toString.toString(item));
}
return sb.toString();
}
public static String ltrim(String s) {
int i = 0;
while (i < s.length() && Character.isWhitespace(s.charAt(i))) {
i++;
}
return s.substring(i);
}
public interface ToString {
ToString DEFAULT = new ToString() {
@Override
public String toString(String o) {
return o;
}
};
String toString(T o);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy