RoutingInstanceConfigurationImpl implements RoutingInstanceConfiguration { @Override public boolean equals(Object obj) { if(!(obj instanceof RoutingInstanceConfiguration)) return false; RoutingInstanceConfiguration o = (RoutingInstanceConfiguration)obj; return (new EqualsBuilder()) .append(getFirstPeer(), o.getFirstPeer()) .append(getSecondPeer(), o.getSecondPeer()) .isEquals(); } RoutingInstanceConfigurationImpl();   RoutingInstanceConfigurationImpl(RoutingPeerConfiguration firstPeer, RoutingPeerConfiguration secondPeer); @Override RoutingPeerConfiguration getFirstPeer(); @Override RoutingPeerConfiguration getSecondPeer(); void setFirstPeer(RoutingPeerConfiguration firstPeer); void setSecondPeer(RoutingPeerConfiguration secondPeer); @Override int compareTo(RoutingInstanceConfiguration o); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals() { AddressFamilyRoutingPeerConfiguration afrpc1aa = 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 afrpc1ab = 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 afrpc1ba = 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 afrpc1bb = 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 afrpc2aa = 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 afrpc2ab = 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 afrpc2ba = 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 afrpc2bb = 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 rpc1a = new RoutingPeerConfigurationImpl("foo1", Arrays.asList(afrpc1aa, afrpc1ba)); RoutingPeerConfiguration rpc1b = new RoutingPeerConfigurationImpl("foo2", Arrays.asList(afrpc1ab, afrpc1bb)); RoutingPeerConfiguration rpc2a = new RoutingPeerConfigurationImpl("foo1", Arrays.asList(afrpc2aa, afrpc2ba)); RoutingPeerConfiguration rpc2b = new RoutingPeerConfigurationImpl("foo2", Arrays.asList(afrpc2ab, afrpc2bb)); Assert.assertTrue(rpc1a.equals(rpc2a)); Assert.assertTrue(rpc1b.equals(rpc2b)); Assert.assertTrue(rpc1b.hashCode() == rpc2b.hashCode()); Assert.assertTrue(rpc1a.compareTo(rpc2a) == 0); Assert.assertTrue(rpc1b.compareTo(rpc2b) == 0); RoutingInstanceConfiguration ric1 = new RoutingInstanceConfigurationImpl(rpc1a, rpc1b); RoutingInstanceConfiguration ric2 = new RoutingInstanceConfigurationImpl(rpc2a, rpc2b); Assert.assertTrue(ric1.equals(ric2)); Assert.assertTrue(ric1.hashCode() == ric2.hashCode()); Assert.assertTrue(ric1.compareTo(ric2) == 0); }