修改断言类,一般使用 Preconditions,需要时使用 PreconditionsExt 即可。

This commit is contained in:
2023-07-19 00:32:08 +08:00
parent 7c37d364d4
commit 3c4310e603
11 changed files with 89 additions and 363 deletions

View File

@@ -18,9 +18,11 @@ package xyz.zhouxy.plusone.commons.domain;
import java.util.regex.Pattern;
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Preconditions;
import xyz.zhouxy.plusone.commons.util.Assert;
import xyz.zhouxy.plusone.commons.util.RegexUtil;
/**
@@ -33,9 +35,9 @@ public abstract class ValidatableStringRecord {
private final String value;
protected ValidatableStringRecord(String value, Pattern pattern) {
Assert.notNull(pattern, "The pattern must not be null.");
Assert.isNotBlank(value, "The value must be has text.");
Assert.isTrue(RegexUtil.matches(value, pattern));
Preconditions.checkNotNull(pattern, "The pattern must not be null.");
Preconditions.checkArgument(StringUtils.isNotBlank(value), "The value must be has text.");
Preconditions.checkArgument(RegexUtil.matches(value, pattern));
this.value = value;
}