Ip4Address { @Override public boolean equals(Object that) { if (that instanceof Ip4Address) { Ip4Address ip4 = (Ip4Address)that; return _addr.equals(ip4._addr) && (_mac == ip4._mac || _mac.equals(ip4._mac)); } else { return false; } } Ip4Address(String addr, String mac);  Ip4Address(long addr, long mac);  Ip4Address(String addr);  Ip4Address(long addr); String ip4(); String mac(); long toLong(); @Override boolean equals(Object that); boolean isSameAddressAs(Object other); @Override int hashCode();  }
@Test public void testEquals() throws Exception { new EqualsTester() .addEqualityGroup(new Ip4Address("0.0.0.1", "00:00:00:00:00:02"), new Ip4Address(1L, 2L)) .addEqualityGroup(new Ip4Address("0.0.0.1", "00:00:00:00:00:00"), new Ip4Address(1L, 0L), new Ip4Address(1L, 0L), new Ip4Address(1L), new Ip4Address("0.0.0.1")) .testEquals(); }