@Test void should_return_false_when_two_instances_have_different_dates() { var i1 = Instant.parse("2019-01-01T12:34:56.789Z"); var i2 = LocalDateTime.of(2020, Month.MAY, 4, 10, 48, 47, 123_000_000).toInstant(ZoneOffset.UTC); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i1, value); var stock2 = new Stock("ABC", i2, value); boolean actual = stock1.equals(stock2); assertThat(actual).isFalse(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); }
Stock { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); } }
Stock { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); } @JsonCreator  Stock(
      @NonNull @JsonProperty("symbol") String symbol,
      @NonNull @JsonProperty("date") Instant date,
      @NonNull @JsonProperty("value") BigDecimal value); }
Stock { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); } @JsonCreator  Stock(
      @NonNull @JsonProperty("symbol") String symbol,
      @NonNull @JsonProperty("date") Instant date,
      @NonNull @JsonProperty("value") BigDecimal value); @NonNull String getSymbol(); @NonNull Instant getDate(); @NonNull BigDecimal getValue(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Stock { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); } @JsonCreator  Stock(
      @NonNull @JsonProperty("symbol") String symbol,
      @NonNull @JsonProperty("date") Instant date,
      @NonNull @JsonProperty("value") BigDecimal value); @NonNull String getSymbol(); @NonNull Instant getDate(); @NonNull BigDecimal getValue(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }