@Test public final void testEquals() { Timestamped<String> a = new Timestamped<>("a", TS_1_1); Timestamped<String> b = new Timestamped<>("b", TS_1_1); assertTrue("value does not impact equality", a.equals(b)); new EqualsTester() .addEqualityGroup(new Timestamped<>("a", TS_1_1), new Timestamped<>("b", TS_1_1), new Timestamped<>("c", TS_1_1)) .addEqualityGroup(new Timestamped<>("a", TS_1_2), new Timestamped<>("b", TS_1_2), new Timestamped<>("c", TS_1_2)) .addEqualityGroup(new Timestamped<>("a", TS_2_1), new Timestamped<>("b", TS_2_1), new Timestamped<>("c", TS_2_1)) .testEquals(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Timestamped)) { return false; } @SuppressWarnings("unchecked") Timestamped<T> that = (Timestamped<T>) obj; return Objects.equals(this.timestamp, that.timestamp); }
Timestamped { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Timestamped)) { return false; } @SuppressWarnings("unchecked") Timestamped<T> that = (Timestamped<T>) obj; return Objects.equals(this.timestamp, that.timestamp); } }
Timestamped { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Timestamped)) { return false; } @SuppressWarnings("unchecked") Timestamped<T> that = (Timestamped<T>) obj; return Objects.equals(this.timestamp, that.timestamp); } Timestamped(T value, Timestamp timestamp); private  Timestamped(); }
Timestamped { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Timestamped)) { return false; } @SuppressWarnings("unchecked") Timestamped<T> that = (Timestamped<T>) obj; return Objects.equals(this.timestamp, that.timestamp); } Timestamped(T value, Timestamp timestamp); private  Timestamped(); T value(); Timestamp timestamp(); boolean isNewer(Timestamped<T> other); boolean isNewerThan(Timestamp other); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
Timestamped { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Timestamped)) { return false; } @SuppressWarnings("unchecked") Timestamped<T> that = (Timestamped<T>) obj; return Objects.equals(this.timestamp, that.timestamp); } Timestamped(T value, Timestamp timestamp); private  Timestamped(); T value(); Timestamp timestamp(); boolean isNewer(Timestamped<T> other); boolean isNewerThan(Timestamp other); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }