@Test void should_return_same_hash_code_when_two_instances_equal() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i, value); var stock2 = new Stock("ABC", i, value); int hashCode1 = stock1.hashCode(); int hashCode2 = stock2.hashCode(); assertThat(hashCode1).isEqualTo(hashCode2); }
@Override public int hashCode() { return Objects.hash(symbol, date, value); }
Stock { @Override public int hashCode() { return Objects.hash(symbol, date, value); } }
Stock { @Override public int hashCode() { return Objects.hash(symbol, date, value); } @JsonCreator  Stock(
      @NonNull @JsonProperty("symbol") String symbol,
      @NonNull @JsonProperty("date") Instant date,
      @NonNull @JsonProperty("value") BigDecimal value); }
Stock { @Override public int hashCode() { return Objects.hash(symbol, date, 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 int hashCode() { return Objects.hash(symbol, date, 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();  }