Deviation implements Serializable { @Override public boolean equals(Object obj) { if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Deviation that = (Deviation) obj; return Objects.equal(item1Id, that.item1Id) && Objects.equal(item2Id, that.item2Id) && Objects.equal(item1TypeId, that.item1TypeId) && Objects.equal(tenantId, that.tenantId) && Objects.equal(item2TypeId, this.item2TypeId); } Deviation(ItemVO<Integer, Integer> item1, ItemVO<Integer, Integer> item2, double numerator,
                     long denominator);  Deviation(@Nullable Integer id, ItemVO<Integer, Integer> item1,
                     ItemVO<Integer, Integer> item2, double numerator, long denominator);  Deviation(int tenantId, int item1Id, int item1TypeId, int item2Id, int item2TypeId, double numerator,
                     long denominator);  Deviation(@Nullable Integer id, int tenantId, int item1Id, int item1TypeId, int item2Id, int item2TypeId,
                     double numerator, long denominator); static long hashCodeOfItems(int item1Id, int item1TypeId, int item2Id, int item2TypeId); long getDenominator(); void setDenominator(long denominator); @Nullable Integer getId(); void setId(@Nullable Integer id); int getItem1Id(); void setItem1Id(int item1Id); int getItem2Id(); void setItem2Id(int item2Id); int getItem1TypeId(); void setItem1TypeId(int item1TypeId); int getItem2TypeId(); void setItem2TypeId(int item2TypeId); double getNumerator(); void setNumerator(double numerator); int getTenantId(); void setTenantId(int tenantId); @Override int hashCode(); @Override String toString(); boolean equalsWithDeviationAndId(Deviation other); boolean equalsWithDeviation(Deviation other); @Override boolean equals(Object obj); double getDeviation(); ItemVO<Integer, Integer> getItem1(); ItemVO<Integer, Integer> getItem2(); long hashCodeOfItems(); void setItem1(ItemVO<Integer, Integer> item1); void setItem2(ItemVO<Integer, Integer> item2); void setItems(ItemVO<Integer, Integer> item1, ItemVO<Integer, Integer> item2);  }
@Test public void testEquals() throws CloneNotSupportedException { Deviation a = new Deviation(1, new ItemVO<Integer, Integer>(1, 1, 1), new ItemVO<Integer, Integer>(1, 2, 1), 10.0, 2); Deviation b = new Deviation(2, new ItemVO<Integer, Integer>(2, 1, 1), new ItemVO<Integer, Integer>(2, 2, 1), 10.0, 2); assertThat("unequal", a, not(equalTo(b))); Deviation a2 = new Deviation(3, new ItemVO<Integer, Integer>(1, 1, 1), new ItemVO<Integer, Integer>(1, 2, 1), 11.0, 3); assertThat("equal", a, equalTo(a2)); }