From 442374e53b23822ae229932cb79c49e4cb7db90c Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Mon, 21 Oct 2024 00:35:10 +0800 Subject: [PATCH] =?UTF-8?q?ValidatableStringRecord=20=E6=9A=82=E4=B8=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/Chinese2ndGenIDCardNumber.java | 1 - .../plusone/commons/model/IDCardNumber.java | 1 - .../model/ValidatableStringRecord.java | 8 +++---- .../model/ValidatableStringRecordTests.java | 21 +------------------ 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/model/Chinese2ndGenIDCardNumber.java b/src/main/java/xyz/zhouxy/plusone/commons/model/Chinese2ndGenIDCardNumber.java index f9add4a..cfbcf0b 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/model/Chinese2ndGenIDCardNumber.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/model/Chinese2ndGenIDCardNumber.java @@ -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; diff --git a/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java b/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java index 855d81a..f6e3114 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java @@ -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{ diff --git a/src/main/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecord.java b/src/main/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecord.java index e3ad9b0..fc63894 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecord.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecord.java @@ -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, Serializable { + implements Comparable { @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; } diff --git a/src/test/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecordTests.java b/src/test/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecordTests.java index e9b93ca..6fd5209 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecordTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/model/ValidatableStringRecordTests.java @@ -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 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 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); }