woody 5 miesięcy temu
rodzic
commit
4908f94fe1

+ 1 - 1
framework-common/src/main/java/com/chelvc/framework/common/model/Paging.java

@@ -157,6 +157,6 @@ public final class Paging implements Serializable {
 
     @Override
     public String toString() {
-        return this.number + "," + this.size;
+        return this.number + "_" + this.size;
     }
 }

+ 1 - 1
framework-common/src/main/java/com/chelvc/framework/common/model/Period.java

@@ -514,7 +514,7 @@ public final class Period implements Serializable {
         if (StringUtils.notEmpty(begin)) {
             buffer.append(begin);
         }
-        buffer.append(",");
+        buffer.append('_');
         String end = DateUtils.format(this.end);
         if (StringUtils.notEmpty(end)) {
             buffer.append(end);

+ 1 - 1
framework-common/src/main/java/com/chelvc/framework/common/model/Range.java

@@ -51,7 +51,7 @@ public final class Range implements Serializable {
         if (StringUtils.notEmpty(this.min)) {
             buffer.append(this.min);
         }
-        buffer.append('\t');
+        buffer.append('_');
         if (StringUtils.notEmpty(this.max)) {
             buffer.append(this.max);
         }

+ 11 - 13
framework-common/src/main/java/com/chelvc/framework/common/util/StringUtils.java

@@ -706,33 +706,31 @@ public final class StringUtils {
     public static <T, U, R> R decompose(String text, @NonNull BiFunction<T, U, R> builder,
                                         @NonNull Function<String, T> parser1,
                                         @NonNull BiFunction<String, T, U> parser2) {
-        if (isEmpty(text) || (text = text.trim()).isEmpty()) {
+        if (isEmpty(text) || (text = text.trim()).isEmpty()
+                || (text.charAt(0) == '(' && text.charAt(text.length() - 1) == ')'
+                && (text = text.substring(1, text.length() - 1).trim()).isEmpty())) {
             return null;
         }
 
-        T first = null;
-        U second = null;
-        if (text.charAt(0) == '(' && text.charAt(text.length() - 1) == ')') {
-            text = text.substring(1, text.length() - 1);
-        }
-        if ((text = text.trim()).isEmpty()) {
-            return null;
-        }
-        String item;
+        // 获取分隔符下标位置
         int delimiter = -1;
         for (int i = 0, max = text.length(); i < max; i++) {
             char c = text.charAt(i);
-            if (c == '\t' || c == ';' || c == ',') {
+            if (c == '_' || c == ',') {
                 delimiter = i;
                 break;
             }
         }
+
+        // 字符串解析
+        String item;
+        T first = null;
+        U second = null;
         if (delimiter < 0) {
             first = parser1.apply(text);
         } else if (delimiter == 0 && !(item = text.substring(1).trim()).isEmpty()) {
             second = parser2.apply(item, null);
-        } else if (delimiter == text.length() - 1
-                && !(item = text.substring(0, text.length() - 1).trim()).isEmpty()) {
+        } else if (delimiter == text.length() - 1 && !(item = text.substring(0, text.length() - 1).trim()).isEmpty()) {
             first = parser1.apply(item);
         } else if (delimiter > 0 && delimiter < text.length() - 1) {
             if (!(item = text.substring(0, delimiter).trim()).isEmpty()) {