diff options
author | Keuin <[email protected]> | 2022-08-13 23:21:23 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-08-13 23:21:23 +0800 |
commit | b068d11b1d8423ae07b7deaf4cdb57b47b828b26 (patch) | |
tree | 08e1410e57a02a105c5dc733e7efc7170d3d6a28 /src/main | |
parent | 9585992947c9bce0ceac47ae70e31963c2492277 (diff) |
Add Pair<K,V> utility class.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/keuin/crosslink/util/Pair.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/crosslink/util/Pair.java b/src/main/java/com/keuin/crosslink/util/Pair.java new file mode 100644 index 0000000..c59c816 --- /dev/null +++ b/src/main/java/com/keuin/crosslink/util/Pair.java @@ -0,0 +1,42 @@ +package com.keuin.crosslink.util; + +import java.util.Objects; + +public class Pair<K, V> { + private final K k; + private final V v; + + public Pair(K k, V v) { + this.k = k; + this.v = v; + } + + public K getK() { + return k; + } + + public V getV() { + return v; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pair<?, ?> pair = (Pair<?, ?>) o; + return Objects.equals(k, pair.k) && Objects.equals(v, pair.v); + } + + @Override + public int hashCode() { + return Objects.hash(k, v); + } + + @Override + public String toString() { + return "Pair{" + + "k=" + k + + ", v=" + v + + '}'; + } +} |