Inet4Datum extends Datum { @Override public boolean equals(Object obj) { if (obj instanceof Inet4Datum) { Inet4Datum other = (Inet4Datum) obj; return this.address == other.address; } return false; } Inet4Datum(int encoded);  Inet4Datum(String addr);  Inet4Datum(byte[] addr);  Inet4Datum(byte[] addr, int offset, int length); @Override int asInt4(); @Override long asInt8(); @Override byte[] asByteArray(); @Override String asChars(); @Override int size(); @Override int hashCode(); @Override boolean equals(Object obj); @Override Datum equalsTo(Datum datum); @Override int compareTo(Datum datum);  }
@Test public final void testEquals() { Inet4Datum ip1 = new Inet4Datum("192.168.0.1"); Inet4Datum ip2 = new Inet4Datum("192.168.0.1"); assertEquals(ip1, ip2); Inet4Datum ip3 = new Inet4Datum(ip1.asByteArray()); assertEquals(ip1, ip3); Inet4Datum ip4 = DatumFactory.createInet4(ip1.asByteArray()); assertEquals(ip1, ip4); }