cn.keayuan.util.Pair Maven / Gradle / Ivy
The newest version!
package cn.keayuan.util;
public class Pair {
public final F first;
public final S second;
public Pair(F first, S second) {
this.first = first;
this.second = second;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Pair)) {
return false;
}
Pair, ?> p = (Pair, ?>) o;
return ObjectUtils.equals(p.first, first) && ObjectUtils.equals(p.second, second);
}
@Override
public int hashCode() {
return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
}
@Override
public String toString() {
return "Pair{" + first + " " + second + "}";
}
public static Pair create(A a, B b) {
return new Pair<>(a, b);
}
}