@Test public void pairWithLeftNullAreEqual() { Pair<Command, Command> pair1 = new Pair<Command, Command>(null, Command.HasData); Pair<Command, Command> pair2 = new Pair<Command, Command>(null, Command.HasData); assertEquals(pair1, pair2); assertEquals(pair1.hashCode(), pair2.hashCode()); }
@Override public int hashCode() { int result = 0; if (left != null) result += left.hashCode(); if (right != null) result = 31 * result + right.hashCode(); return result; }
Pair { @Override public int hashCode() { int result = 0; if (left != null) result += left.hashCode(); if (right != null) result = 31 * result + right.hashCode(); return result; } }
Pair { @Override public int hashCode() { int result = 0; if (left != null) result += left.hashCode(); if (right != null) result = 31 * result + right.hashCode(); return result; } Pair(T left, U right); }
Pair { @Override public int hashCode() { int result = 0; if (left != null) result += left.hashCode(); if (right != null) result = 31 * result + right.hashCode(); return result; } Pair(T left, U right); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
Pair { @Override public int hashCode() { int result = 0; if (left != null) result += left.hashCode(); if (right != null) result = 31 * result + right.hashCode(); return result; } Pair(T left, U right); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); public T left; public U right; }