From 0b0c34a930b23aac60629c7b24b45bde1c3bbc3e Mon Sep 17 00:00:00 2001 From: MiniDay <372403923@qq.com> Date: Fri, 4 Nov 2022 00:51:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mc/plugin/core/common/util/Pair.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 hamster-core-common/src/main/java/cn/hamster3/mc/plugin/core/common/util/Pair.java diff --git a/hamster-core-common/src/main/java/cn/hamster3/mc/plugin/core/common/util/Pair.java b/hamster-core-common/src/main/java/cn/hamster3/mc/plugin/core/common/util/Pair.java new file mode 100644 index 0000000..982eadb --- /dev/null +++ b/hamster-core-common/src/main/java/cn/hamster3/mc/plugin/core/common/util/Pair.java @@ -0,0 +1,52 @@ +package cn.hamster3.mc.plugin.core.common.util; + +import org.jetbrains.annotations.NotNull; + +import java.io.Serializable; +import java.util.Objects; + +/** + *
A convenience class to represent name-value pairs.
+ */ +@SuppressWarnings({"unused", "ClassCanBeRecord"}) +public class PairPair
.
+ */
+ @NotNull
+ private final K key;
+
+ /**
+ * Value of this this Pair
.
+ */
+ @NotNull
+ private final V value;
+
+ public Pair(@NotNull K key, @NotNull V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @NotNull
+ public K getKey() {
+ return key;
+ }
+
+ @NotNull
+ public V getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Pair, ?> pair = (Pair, ?>) o;
+ return key.equals(pair.key) && value.equals(pair.value);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(key, value);
+ }
+}