1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-13 21:05:01 -05:00
filebot/source/net/sourceforge/tuned/StringUtilities.java
Reinhard Pointner c93377010c * print version/revision/jre identifier
* just print help if started with no arguments in headless mode instead of crashing when trying to start the GUI
2011-11-29 03:14:39 +00:00

53 lines
1019 B
Java

package net.sourceforge.tuned;
import static java.util.Arrays.*;
import java.util.Iterator;
public final class StringUtilities {
public static boolean isEmptyValue(Object object) {
return object == null || object.toString().length() == 0;
}
public static String joinBy(CharSequence delimiter, Object... values) {
return join(asList(values), delimiter);
}
public static String join(Object[] values, CharSequence delimiter) {
return join(asList(values), delimiter);
}
public static String join(Iterable<?> values, CharSequence delimiter) {
StringBuilder sb = new StringBuilder();
for (Iterator<?> iterator = values.iterator(); iterator.hasNext();) {
Object value = iterator.next();
if (!isEmptyValue(value)) {
if (sb.length() > 0) {
sb.append(delimiter);
}
sb.append(value);
}
}
return sb.toString();
}
/**
* Dummy constructor to prevent instantiation.
*/
private StringUtilities() {
throw new UnsupportedOperationException();
}
}