测试工具类

This commit is contained in:
yuejiajun 2025-09-29 14:28:05 +08:00
parent 2af0646d25
commit 91428f8a90
2 changed files with 898 additions and 932 deletions

View File

@ -164,6 +164,7 @@ public class FormatUtil {
* @return 截取后的字符串 * @return 截取后的字符串
*/ */
public static String substring(String str, Map<String, Object> params) { public static String substring(String str, Map<String, Object> params) {
try {
if (str == null) return null; if (str == null) return null;
int start = params.containsKey("start") ? Integer.parseInt(params.get("start").toString()) : 0; int start = params.containsKey("start") ? Integer.parseInt(params.get("start").toString()) : 0;
@ -180,6 +181,10 @@ public class FormatUtil {
} else { } else {
return str.substring(start); return str.substring(start);
} }
} catch (Exception e) {
log.warn("str 截取失败,{}", str, e);
return "";
}
} }
/** /**
@ -1380,7 +1385,7 @@ public class FormatUtil {
String strategy = params.containsKey("strategy") ? params.get("strategy").toString() : "clamp"; String strategy = params.containsKey("strategy") ? params.get("strategy").toString() : "clamp";
switch (strategy) { switch (strategy) {
case "clamp": case "clamp", "truncate":
if (value < min) return min; if (value < min) return min;
if (value > max) return max; if (value > max) return max;
return value; return value;

File diff suppressed because it is too large Load Diff