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..5c28173 --- /dev/null +++ b/hamster-core-common/src/main/java/cn/hamster3/mc/plugin/core/common/util/Pair.java @@ -0,0 +1,43 @@ +package cn.hamster3.mc.plugin.core.common.util; + +import org.jetbrains.annotations.NotNull; + +import java.io.Serializable; +import java.util.Objects; + +@SuppressWarnings("unused") +public class Pair implements Serializable { + @NotNull + private final K key; + + @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); + } +}