Inet4Datum extends Datum { @Override public byte[] asByteArray() { byte[] addr = new byte[size]; addr[0] = (byte) ((address >>> 24) & 0xFF); addr[1] = (byte) ((address >>> 16) & 0xFF); addr[2] = (byte) ((address >>> 8) & 0xFF); addr[3] = (byte) (address & 0xFF); return addr; } 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 testAsByteArray() { byte[] bytes = {(byte) 0xA3, (byte) 0x98, 0x17, (byte) 0xDE}; Inet4Datum ip = new Inet4Datum(bytes); assertTrue(Arrays.equals(bytes, ip.asByteArray())); }