ValidatableStringRecord 暂不支持序列化

dev
ZhouXY108 2024-10-21 00:35:10 +08:00
parent 85939e4fc4
commit 442374e53b
4 changed files with 4 additions and 27 deletions

View File

@ -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;

View File

@ -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{

View File

@ -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;
}

View File

@ -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);
}