RoutingPeerConfigurationImpl implements RoutingPeerConfiguration { @Override public boolean equals(Object obj) { if(!(obj instanceof RoutingPeerConfiguration)) return false; RoutingPeerConfiguration o = (RoutingPeerConfiguration)obj; EqualsBuilder builder = (new EqualsBuilder()) .append(getPeerName(), o.getPeerName()) .append(getAddressFamilyConfigrations().size(), o.getAddressFamilyConfigrations().size()); if(builder.isEquals()) { Iterator<AddressFamilyRoutingPeerConfiguration> lit = getAddressFamilyConfigrations().iterator(); Iterator<AddressFamilyRoutingPeerConfiguration> rit = o.getAddressFamilyConfigrations().iterator(); while(lit.hasNext()) builder.append(lit.next(), rit.next()); } return builder.isEquals(); } RoutingPeerConfigurationImpl();   RoutingPeerConfigurationImpl(String peerName, Collection<AddressFamilyRoutingPeerConfiguration> addressFamilyConfigrations); @Override String getPeerName(); @Override Set<AddressFamilyRoutingPeerConfiguration> getAddressFamilyConfigrations(); @Override int compareTo(RoutingPeerConfiguration o); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals() { AddressFamilyRoutingPeerConfiguration afrpc1a = new AddressFamilyRoutingPeerConfigurationImpl(AddressFamilyKey.IPV4_UNICAST_FORWARDING, Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x01})))), Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x02})))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(100), (PathAttribute)new MultiExitDiscPathAttribute(1))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(200), (PathAttribute)new MultiExitDiscPathAttribute(2)))); AddressFamilyRoutingPeerConfiguration afrpc1b = new AddressFamilyRoutingPeerConfigurationImpl(AddressFamilyKey.IPV6_UNICAST_FORWARDING, Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x01})))), Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x02})))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(100), (PathAttribute)new MultiExitDiscPathAttribute(1))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(200), (PathAttribute)new MultiExitDiscPathAttribute(2)))); AddressFamilyRoutingPeerConfiguration afrpc2a = new AddressFamilyRoutingPeerConfigurationImpl(AddressFamilyKey.IPV4_UNICAST_FORWARDING, Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x01})))), Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x02})))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(100), (PathAttribute)new MultiExitDiscPathAttribute(1))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(200), (PathAttribute)new MultiExitDiscPathAttribute(2)))); AddressFamilyRoutingPeerConfiguration afrpc2b = new AddressFamilyRoutingPeerConfigurationImpl(AddressFamilyKey.IPV6_UNICAST_FORWARDING, Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x01})))), Arrays.asList((RoutingFilterConfiguration)new PrefixRoutingFilterConfigurationImpl("foo", Arrays.asList(new NetworkLayerReachabilityInformation(24, new byte[] {(byte)0xc0, (byte)0xa8, 0x02})))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(100), (PathAttribute)new MultiExitDiscPathAttribute(1))), new PathAttributeConfigurationImpl(Arrays.asList((PathAttribute)new LocalPrefPathAttribute(200), (PathAttribute)new MultiExitDiscPathAttribute(2)))); RoutingPeerConfiguration rpc1 = new RoutingPeerConfigurationImpl("foo", Arrays.asList(afrpc1a, afrpc1b)); RoutingPeerConfiguration rpc2 = new RoutingPeerConfigurationImpl("foo", Arrays.asList(afrpc2b, afrpc2a)); Assert.assertTrue(rpc1.equals(rpc2)); Assert.assertTrue(rpc1.hashCode() == rpc2.hashCode()); Assert.assertTrue(rpc1.compareTo(rpc2) == 0); }