AddressFamilyKey implements Comparable<AddressFamilyKey> { @Override public boolean equals(Object obj) { if(!(obj instanceof AddressFamilyKey)) return false; AddressFamilyKey o = (AddressFamilyKey)obj; return (new EqualsBuilder()) .append(addressFamily, o.addressFamily) .append(subsequentAddressFamily, o.subsequentAddressFamily) .isEquals(); } AddressFamilyKey(AddressFamily addressFamily, SubsequentAddressFamily subsequentAddressFamily); AddressFamily getAddressFamily(); SubsequentAddressFamily getSubsequentAddressFamily(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(AddressFamilyKey o); boolean matches(AddressFamily afi, SubsequentAddressFamily safi); static final AddressFamilyKey IPV4_UNICAST_FORWARDING; static final AddressFamilyKey IPV6_UNICAST_FORWARDING; }
@Test public void testEquals() { AddressFamilyKey k1 = new AddressFamilyKey(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); AddressFamilyKey k2 = new AddressFamilyKey(AddressFamily.IPv4, SubsequentAddressFamily.NLRI_UNICAST_FORWARDING); Assert.assertTrue(k1.equals(k2)); Assert.assertTrue(k1.hashCode() == k2.hashCode()); Assert.assertTrue(k1.compareTo(k2) == 0); }