|
@@ -102,6 +102,10 @@ public class StrKit {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static String defaultIfBlank(String src, String defaultValue) {
|
|
|
|
|
+ return isBlank(src) ? defaultValue : src;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static String toCamelCase(String stringWithUnderline) {
|
|
public static String toCamelCase(String stringWithUnderline) {
|
|
|
if (stringWithUnderline.indexOf('_') == -1) {
|
|
if (stringWithUnderline.indexOf('_') == -1) {
|
|
|
return stringWithUnderline;
|
|
return stringWithUnderline;
|
|
@@ -145,6 +149,17 @@ public class StrKit {
|
|
|
return sb.toString();
|
|
return sb.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static String join(java.util.List<String> list, String separator) {
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
+ for (int i=0, len=list.size(); i<len; i++) {
|
|
|
|
|
+ if (i > 0) {
|
|
|
|
|
+ sb.append(separator);
|
|
|
|
|
+ }
|
|
|
|
|
+ sb.append(list.get(i));
|
|
|
|
|
+ }
|
|
|
|
|
+ return sb.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static boolean slowEquals(String a, String b) {
|
|
public static boolean slowEquals(String a, String b) {
|
|
|
byte[] aBytes = (a != null ? a.getBytes() : null);
|
|
byte[] aBytes = (a != null ? a.getBytes() : null);
|
|
|
byte[] bBytes = (b != null ? b.getBytes() : null);
|
|
byte[] bBytes = (b != null ? b.getBytes() : null);
|