@Test public void testEquals() throws Exception { String[] array = new String[] {"first", "second", "third"}; Triplet<String, String, String> triplet = Triplet.fromArray(array); String[] otherArray = new String[] {"first", "second", "third"}; Triplet<String, String, String> otherTriplet = Triplet.fromArray(array); assertTrue(triplet.equals(otherTriplet)); otherArray[0] = "other"; assertFalse(triplet.equals(Triplet.fromArray(otherArray))); array[0] = null; otherArray[0] = null; assertTrue(Triplet.fromArray(array).equals(Triplet.fromArray(otherArray))); otherArray[1] = null; assertFalse(Triplet.fromArray(array).equals(Triplet.fromArray(otherArray))); }
@Override public boolean equals(Object o) { if (o instanceof Triplet) { Triplet other = (Triplet) o; return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second) && Objects.equals(this.third, other.third); } return false; }
Triplet implements Serializable { @Override public boolean equals(Object o) { if (o instanceof Triplet) { Triplet other = (Triplet) o; return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second) && Objects.equals(this.third, other.third); } return false; } }
Triplet implements Serializable { @Override public boolean equals(Object o) { if (o instanceof Triplet) { Triplet other = (Triplet) o; return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second) && Objects.equals(this.third, other.third); } return false; } Triplet(A first, B second, C third); }
Triplet implements Serializable { @Override public boolean equals(Object o) { if (o instanceof Triplet) { Triplet other = (Triplet) o; return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second) && Objects.equals(this.third, other.third); } return false; } Triplet(A first, B second, C third); static Triplet<A, B, C> of(A first, B second, C third); static Triplet<A, A, A> fromArray(A[] array); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); A first(); B second(); C third(); }
Triplet implements Serializable { @Override public boolean equals(Object o) { if (o instanceof Triplet) { Triplet other = (Triplet) o; return Objects.equals(this.first, other.first) && Objects.equals(this.second, other.second) && Objects.equals(this.third, other.third); } return false; } Triplet(A first, B second, C third); static Triplet<A, B, C> of(A first, B second, C third); static Triplet<A, A, A> fromArray(A[] array); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); A first(); B second(); C third();  }