GroupAddress { @Override public boolean equals(Object o) { if (o == null) return false; if (!o.getClass().equals(this.getClass())) return false; GroupAddress addr = (GroupAddress)o; return addr.hiByte == this.hiByte && addr.loByte == this.loByte; } GroupAddress(String groupAddress);   GroupAddress(byte hibyte, byte lobyte); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() throws InvalidGroupAddressException { GroupAddress a1 = new GroupAddress("0/0/0"); GroupAddress a2 = new GroupAddress("0/0/0"); GroupAddress a3 = new GroupAddress("31/7/255"); GroupAddress a4 = new GroupAddress("31/7/255"); Assert.assertTrue("Expecting A1 to equals A2", a1.equals(a2)); Assert.assertTrue("Expecting A2 to equal A1", a2.equals(a1)); Assert.assertFalse("Expecting A1 NOT to equal A3", a1.equals(a3)); Assert.assertFalse("Expecting A3 NOT to equal A1", a3.equals(a1)); Assert.assertTrue("Expecting A3 equals A4", a3.equals(a4)); Assert.assertTrue("Expecting A4 equals A3", a4.equals(a3)); Assert.assertFalse(a1.equals(null)); Assert.assertFalse(a1.equals(new Object())); }