Inet4Datum extends Datum { @Override public int compareTo(Datum datum) { switch (datum.type()) { case INET4: byte[] bytes = asByteArray(); byte[] other = datum.asByteArray(); return Bytes.compareTo(bytes, 0, size, other, 0, size); case NULL_TYPE: return -1; default: throw new InvalidOperationException(datum.type()); } } 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 testGreaterThan() { Inet4Datum ip1 = new Inet4Datum("193.168.0.1"); Inet4Datum ip2 = new Inet4Datum("192.168.100.1"); assertEquals(ip1.compareTo(ip2), 1); }
@Test public final void testLessThan() { Inet4Datum ip1 = new Inet4Datum("192.168.100.1"); Inet4Datum ip2 = new Inet4Datum("193.168.0.1"); assertEquals(ip1.compareTo(ip2), -1); }