From b08562adaf79935c7974251945eedd7ea454b8ec Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sun, 7 Apr 2024 16:45:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20jackson-annotations=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 ------ .../domain/ValidatableStringRecord.java | 22 ++++++++++++++++--- .../plusone/commons/util/RestfulResult.java | 2 -- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index fb3b5f3..47d244b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,6 @@ 8 1.8 1.8 - 2.13.5 3.13.0 32.1.3-jre 3.0.2 @@ -21,12 +20,6 @@ - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - com.google.guava guava diff --git a/src/main/java/xyz/zhouxy/plusone/commons/domain/ValidatableStringRecord.java b/src/main/java/xyz/zhouxy/plusone/commons/domain/ValidatableStringRecord.java index 794861e..8cf859d 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/domain/ValidatableStringRecord.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/domain/ValidatableStringRecord.java @@ -16,11 +16,11 @@ package xyz.zhouxy.plusone.commons.domain; +import java.util.Objects; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; -import com.fasterxml.jackson.annotation.JsonValue; import com.google.common.base.Preconditions; import xyz.zhouxy.plusone.commons.util.RegexTools; @@ -37,7 +37,7 @@ public abstract class ValidatableStringRecord protected ValidatableStringRecord(String value, Pattern pattern) { Preconditions.checkNotNull(pattern, "The pattern must not be null."); - Preconditions.checkArgument(StringUtils.isNotBlank(value), "The value must be has text."); + Preconditions.checkNotNull(StringUtils.isNotBlank(value), "The value must not be null."); Preconditions.checkArgument(RegexTools.matches(value, pattern)); this.value = value; } @@ -47,7 +47,6 @@ public abstract class ValidatableStringRecord * * @return 字符串(不为空) */ - @JsonValue public final String value() { return this.value; } @@ -57,6 +56,23 @@ public abstract class ValidatableStringRecord return this.value.compareTo(o.value); } + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ValidatableStringRecord other = (ValidatableStringRecord) obj; + return Objects.equals(value, other.value); + } + @Override public String toString() { return this.value(); diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java b/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java index 968563c..16a6b49 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/RestfulResult.java @@ -21,7 +21,6 @@ import java.util.function.Supplier; import javax.annotation.Nullable; -import com.fasterxml.jackson.annotation.JsonInclude; import com.google.common.base.Preconditions; /** @@ -31,7 +30,6 @@ import com.google.common.base.Preconditions; * @deprecated 已被 {@link UnifiedResponse} 代替。 */ @Deprecated -@JsonInclude(JsonInclude.Include.NON_NULL) public class RestfulResult { public static final int SUCCESS_STATUS = 2000000;