001package gudusoft.gsqlparser.dlineage.util;
002
003public class Pair<F, S> {
004
005    public final F first;
006    public final S second;
007
008    public Pair(F left, S right) {
009        this.first = left;
010        this.second = right;
011    }
012
013    @Override
014    public boolean equals(Object obj) {
015        if (this == obj) return true;
016        if (!(obj instanceof Pair)) return false;
017        Pair<?, ?> other = (Pair<?, ?>) obj;
018        return Objects.equal(first, other.first) && Objects.equal(second, other.second);
019    }
020
021    @Override
022    public int hashCode() {
023        int hash1 = first != null ? first.hashCode() : 0;
024        int hash2 = second != null ? second.hashCode() : 0;
025        return hash1 ^ hash2;
026    }
027
028    public static <A, B> Pair<A, B> create(A left, B right) {
029        return new Pair<>(left, right);
030    }
031
032    @Override
033    public String toString() {
034        return "[" + first + "," + second + "]";
035    }
036}