|
|
@@ -15,6 +15,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
+import java.util.NoSuchElementException;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
@@ -1008,6 +1009,24 @@ public final class StringUtils {
|
|
|
return replace(replaceEndl(text), '\037', "\r\n");
|
|
|
}
|
|
|
|
|
|
+ public static String firstNotEmpty(String... values) {
|
|
|
+ for(String value : values) {
|
|
|
+ if(!StringTraits.isEmpty(value)) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new NoSuchElementException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String firstNotBlank(String... values) {
|
|
|
+ for(String value : values) {
|
|
|
+ if(!StringTraits.isBlank(value)) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new NoSuchElementException();
|
|
|
+ }
|
|
|
+
|
|
|
private static String replaceEndl(String text) {
|
|
|
return text.replaceAll("\r\n", "\037").replace('\n', '\037').replace('\r', '\037');
|
|
|
}
|