正则相关的操作由 RegexUtil 负责。
parent
d05fcbfc9c
commit
87942d708a
|
@ -1,9 +1,5 @@
|
|||
package xyz.zhouxy.plusone.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
@ -27,17 +23,4 @@ public class PlusoneStrUtil {
|
|||
return StringUtils.hasLength(value) ? value : EMPTY_STR;
|
||||
}
|
||||
|
||||
public static String checkString(String value, String regex, String message) {
|
||||
Assert.notNull(value, message);
|
||||
Assert.isTrue(Pattern.matches(regex, value), message);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String checkStringNullable(String value, String regex, String message) {
|
||||
return Objects.nonNull(value) ? checkString(value, regex, message) : null;
|
||||
}
|
||||
|
||||
public static String checkStringOrDefault(String value, String regex, String message) {
|
||||
return StringUtils.hasText(value) ? checkString(value, regex, message) : "";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue