refactor(common): 允许 pair 中使用 null 值

This commit is contained in:
2023-01-19 12:02:40 +08:00
parent 21f0524b63
commit 502ff3c39d

View File

@@ -1,29 +1,22 @@
package cn.hamster3.mc.plugin.core.common.util; package cn.hamster3.mc.plugin.core.common.util;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class Pair<K, V> implements Serializable { public class Pair<K, V> implements Serializable {
@NotNull
private final K key; private final K key;
@NotNull
private final V value; private final V value;
public Pair(@NotNull K key, @NotNull V value) { public Pair(K key, V value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@NotNull
public K getKey() { public K getKey() {
return key; return key;
} }
@NotNull
public V getValue() { public V getValue() {
return value; return value;
} }
@@ -33,7 +26,7 @@ public class Pair<K, V> implements Serializable {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Pair<?, ?> pair = (Pair<?, ?>) o; Pair<?, ?> pair = (Pair<?, ?>) o;
return key.equals(pair.key) && value.equals(pair.value); return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
} }
@Override @Override