1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-11 11:55:03 -05:00
filebot/source/net/sourceforge/tuned/StringUtilities.java
Reinhard Pointner 373b0c2662 * allow manual input if no subtitles have been found via auto-matching
* allow multi-value input in input dialog
* make sure background workers get cancelled / terminated as expected
2011-11-28 10:24:46 +00:00

48 lines
897 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 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();
}
}