@Test public void testEquals() { Pair pair = new Pair("lhs", "rhs"); Assert.assertTrue(pair.equals(pair)); Assert.assertTrue(pair.equals(new Pair("lhs", "rhs"))); Assert.assertFalse(pair.equals(null)); Assert.assertFalse(pair.equals(new Pair(null, "rhs"))); Assert.assertFalse(pair.equals(new Pair("lhs", null))); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Pair pair = (Pair) o; if (lhs != null ? !lhs.equals(pair.lhs) : pair.lhs != null) { return false; } if (rhs != null ? !rhs.equals(pair.rhs) : pair.rhs != null) { return false; } return true; }
Pair { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Pair pair = (Pair) o; if (lhs != null ? !lhs.equals(pair.lhs) : pair.lhs != null) { return false; } if (rhs != null ? !rhs.equals(pair.rhs) : pair.rhs != null) { return false; } return true; } }
Pair { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Pair pair = (Pair) o; if (lhs != null ? !lhs.equals(pair.lhs) : pair.lhs != null) { return false; } if (rhs != null ? !rhs.equals(pair.rhs) : pair.rhs != null) { return false; } return true; } Pair(T1 lhs, T2 rhs); }
Pair { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Pair pair = (Pair) o; if (lhs != null ? !lhs.equals(pair.lhs) : pair.lhs != null) { return false; } if (rhs != null ? !rhs.equals(pair.rhs) : pair.rhs != null) { return false; } return true; } Pair(T1 lhs, T2 rhs); static Pair<T1, T2> of(T1 lhs, T2 rhs); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Function<Pair<T1, T2>, T1> lhsFn(); static Function<Pair<T1, T2>, T2> rhsFn(); static Comparator<Pair<T1, ?>> lhsComparator(final Comparator<T1> comparator); }
Pair { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Pair pair = (Pair) o; if (lhs != null ? !lhs.equals(pair.lhs) : pair.lhs != null) { return false; } if (rhs != null ? !rhs.equals(pair.rhs) : pair.rhs != null) { return false; } return true; } Pair(T1 lhs, T2 rhs); static Pair<T1, T2> of(T1 lhs, T2 rhs); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Function<Pair<T1, T2>, T1> lhsFn(); static Function<Pair<T1, T2>, T2> rhsFn(); static Comparator<Pair<T1, ?>> lhsComparator(final Comparator<T1> comparator); final T1 lhs; final T2 rhs; }