NumEntries { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof NumEntries) { NumEntries other = (NumEntries) obj; return size == other.size && isExact == other.isExact; } else { return false; } } private  NumEntries(long size, boolean isExact); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals() { assertEquals(NumEntries.ZERO, NumEntries.ZERO); NumEntries ne1True = NumEntries.valueOf(1, true); NumEntries ne2True = NumEntries.valueOf(2, true); NumEntries ne1False = NumEntries.valueOf(1, false); assertEquals(ne1True, ne1True); assertNotEquals(ne1False, ne1True); assertNotEquals(ne2True, ne1True); assertFalse(ne1True.equals(null)); assertFalse(ne1True.equals(new Object())); }