Ip4Address { public boolean isSameAddressAs(Object other) { if (other instanceof String) { return _addr.equals(other); } else { return equals(other); } } 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 testIsSameAddressAs() { Assert.assertTrue("1 and one should be considdered the same address", new Ip4Address(1L, 5L).isSameAddressAs("0.0.0.1")); Assert.assertFalse("zero and 0L should be considdered the same address but a Long won't be accepted", new Ip4Address("0.0.0.0", "00:00:00:00:00:08").isSameAddressAs(0L)); }