Ip implements Serializable, Comparable<Ip> { public boolean isSameAddressAs(Object obj) { if (this.equals(obj)) { return true; } else if (obj instanceof String) { return ip == NetUtils.ip2Long((String)obj); } else if (obj instanceof Long) { return ip == (Long)obj; } else { return false; } } Ip(long ip);  Ip(String ip); protected  Ip(); String addr(); long longValue(); @Override String toString(); boolean isIp4(); boolean isIp6(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isSameAddressAs(Object obj); @Override int compareTo(Ip that);  }
@Test public void testIsSameAddressAs() { Assert.assertTrue("1 and one should be considdered the same address", new Ip(1L).isSameAddressAs("0.0.0.1")); Assert.assertTrue("zero and 0L should be considdered the same address", new Ip("0.0.0.0").isSameAddressAs(0L)); }