SnmpConfigurationImpl implements SnmpConfiguration { @Override public boolean equals(Object obj) { if(!(obj instanceof SnmpConfiguration)) return false; SnmpConfiguration o = (SnmpConfiguration)obj; return (new EqualsBuilder()) .append(getTargetAddress(), o.getTargetAddress()) .append(getCommunity(), o.getCommunity()) .append(getLocalPort(), o.getLocalPort()) .isEquals(); } SnmpConfigurationImpl();   SnmpConfigurationImpl(InetAddress address, String community); @Override InetAddress getTargetAddress(); @Override String getCommunity(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int getLocalPort();  }
@Test public void testEquals() throws Exception { SnmpConfiguration s1 = new SnmpConfigurationImpl(InetAddress.getByAddress(new byte[] { (byte)0xc0, (byte)0xa8, 0x01, 0x01 }), "dummy"); SnmpConfiguration s2 = new SnmpConfigurationImpl(InetAddress.getByAddress(new byte[] { (byte)0xc0, (byte)0xa8, 0x01, 0x01 }), "dummy"); SnmpConfiguration s3 = new SnmpConfigurationImpl(InetAddress.getByAddress(new byte[] { (byte)0xc0, (byte)0xa8, 0x01, 0x02 }), "dummy"); SnmpConfiguration s4 = new SnmpConfigurationImpl(InetAddress.getByAddress(new byte[] { (byte)0xc0, (byte)0xa8, 0x01, 0x01 }), "foo"); Assert.assertTrue(s1.equals(s2)); Assert.assertFalse(s1.equals(s3)); Assert.assertFalse(s1.equals(s4)); }