forked from plusone/plusone-commons
ValidatableStringRecord 暂不支持序列化
parent
85939e4fc4
commit
442374e53b
|
@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
* 中国第二代居民身份证号
|
||||
*/
|
||||
public class Chinese2ndGenIDCardNumber extends IDCardNumber {
|
||||
private static final long serialVersionUID = 20241011231542L;
|
||||
|
||||
/** 省份编码 */
|
||||
private final String provinceCode;
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.annotation.Nonnull;
|
|||
* 身份证号
|
||||
*/
|
||||
public abstract class IDCardNumber extends ValidatableStringRecord {
|
||||
private static final long serialVersionUID = 20241011231527L;
|
||||
|
||||
protected IDCardNumber(@Nonnull String idNumber, @Nonnull Pattern pattern)
|
||||
throws IllegalArgumentException{
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package xyz.zhouxy.plusone.commons.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -33,12 +32,12 @@ import xyz.zhouxy.plusone.commons.util.AssertTools;
|
|||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class ValidatableStringRecord
|
||||
implements Comparable<ValidatableStringRecord>, Serializable {
|
||||
implements Comparable<ValidatableStringRecord> {
|
||||
|
||||
@Nonnull
|
||||
private final String value;
|
||||
|
||||
private final transient Matcher matcher;
|
||||
private final Matcher matcher;
|
||||
|
||||
protected ValidatableStringRecord(@Nonnull String value, @Nonnull Pattern pattern) {
|
||||
this(value, pattern, "Invalid value");
|
||||
|
@ -60,7 +59,7 @@ public abstract class ValidatableStringRecord
|
|||
|
||||
/**
|
||||
* 值对象的字符串值。
|
||||
*
|
||||
*
|
||||
* @return 字符串(不为空)
|
||||
*/
|
||||
public final String value() {
|
||||
|
@ -98,5 +97,4 @@ public abstract class ValidatableStringRecord
|
|||
return matcher;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -8365241662025469652L;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package xyz.zhouxy.plusone.commons.model;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -34,7 +33,6 @@ import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
|
|||
import xyz.zhouxy.plusone.commons.annotation.ValueObject;
|
||||
import xyz.zhouxy.plusone.commons.constant.PatternConsts;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -62,25 +60,12 @@ class ValidatableStringRecordTests {
|
|||
Function<Username, String> compare = o -> o.value().toLowerCase();
|
||||
log.info("{}", Collections.max(usernames, Comparator.comparing(compare)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerial() {
|
||||
User obj = new User(Username.of("zhouxy"), Email.of("zhouxy@outlook.com"));
|
||||
User snapshot = ObjectUtil.clone(obj);
|
||||
obj.setUsername(Username.of("ZhouXY108"));
|
||||
log.info("snapshot: {}", snapshot);
|
||||
log.info("obj: {}", obj);
|
||||
|
||||
DiffResult<User> userDiffResult = User.Diff.diff(snapshot, obj);
|
||||
log.info("userDiffResult: {}", userDiffResult);
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
class User implements Serializable {
|
||||
private static final long serialVersionUID = 3549288698636099823L;
|
||||
class User {
|
||||
Username username;
|
||||
Email email;
|
||||
|
||||
|
@ -100,8 +85,6 @@ class User implements Serializable {
|
|||
|
||||
@ValueObject
|
||||
class Email extends ValidatableStringRecord {
|
||||
private static final long serialVersionUID = -2092385577843676401L;
|
||||
|
||||
private Email(String value) {
|
||||
super(value, PatternConsts.EMAIL);
|
||||
}
|
||||
|
@ -114,8 +97,6 @@ class Email extends ValidatableStringRecord {
|
|||
|
||||
@ValueObject
|
||||
class Username extends ValidatableStringRecord {
|
||||
private static final long serialVersionUID = -7105647514140482394L;
|
||||
|
||||
private Username(String username) {
|
||||
super(username, PatternConsts.USERNAME);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue