public class Tuple { public Integer first; public Integer second; public Tuple() { } public Tuple(Integer first, Integer second) { this.first = first; this.second = second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Tuple that = (Tuple) o; if (first != null ? !first.equals(that.first) : that.first != null) return false; return second != null ? second.equals(that.second) : that.second == null; } }