Email { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Email)) { return false; } Email other = (Email) obj; return Objects.equals(this.address, other.address) && Objects.equals(this.verified, other.verified) && Objects.equals(this.verificationToken, other.verificationToken); } @JsonCreator  Email(@JsonProperty("address") String address,
               @JsonProperty("verified") boolean verified,
               @JsonProperty("verificationToken") String verificationToken); String getAddress(); String getVerificationToken(); boolean isVerified(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test @SuppressWarnings({"ConstantConditions", "ObjectEqualsNull"}) void equalsShouldWorkCorrectly() { assertAll("Basic equals properties", () -> assertTrue(!email.equals(null), "Email must not be equal to null"), () -> assertTrue(!email.equals(new Object()), "Email must not be equal to another type"), () -> assertEquals(email, email, "Email must be equal to itself")); Email differentAddress = new Email("bad@email.com", true, "token"); Email differentVerified = new Email("test@test.com", false, "token"); Email differentToken = new Email("test@test.com", true, "badToken"); Email sameEmail = new Email("test@test.com", true, "token"); assertAll("Verify against other created objects", () -> assertNotEquals(differentAddress, email), () -> assertNotEquals(differentVerified, email), () -> assertNotEquals(differentToken, email), () -> assertEquals(sameEmail, email)); }