org.bitcoinj.utils.Pair Maven / Gradle / Ivy
package org.bitcoinj.utils;
import java.util.Comparator;
/**
* Created by Eric on 2/24/2016.
*/
public class Pair {
private First first;
private Second second;
public Pair(First first, Second second) {
this.first = first;
this.second = second;
}
public void setFirst(First first) {
this.first = first;
}
public void setSecond(Second second) {
this.second = second;
}
public First getFirst() {
return first;
}
public Second getSecond() {
return second;
}
public void set(First first, Second second) {
setFirst(first);
setSecond(second);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair pair = (Pair) o;
if (first != null ? !first.equals(pair.first) : pair.first != null) return false;
if (second != null ? !second.equals(pair.second) : pair.second != null) return false;
return true;
}
@Override
public int hashCode() {
int result = first != null ? first.hashCode() : 0;
result = 31 * result + (second != null ? second.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "["+first.toString()+", "+second.toString()+"]";
}
}