From b068d11b1d8423ae07b7deaf4cdb57b47b828b26 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 13 Aug 2022 23:21:23 +0800 Subject: Add Pair utility class. --- src/main/java/com/keuin/crosslink/util/Pair.java | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/keuin/crosslink/util/Pair.java 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 { + 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 + + '}'; + } +} -- cgit v1.2.3