CharDatum extends Datum { @Override public int compareTo(Datum datum) { switch (datum.type()) { case CHAR: case TEXT: return UnsignedBytes.lexicographicalComparator().compare(bytes, datum.asByteArray()); case NULL_TYPE: return -1; default: throw new InvalidOperationException(datum.type()); } } CharDatum(byte val);  CharDatum(char val);  CharDatum(byte [] bytes);  CharDatum(String val); @Override char asChar(); @Override short asInt2(); @Override int asInt4(); @Override long asInt8(); @Override byte[] asByteArray(); @Override float asFloat4(); @Override double asFloat8(); @Override byte asByte(); @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 testCompare() { Datum a = DatumFactory.createChar("abc"); Datum b = DatumFactory.createChar("abd"); Datum c = DatumFactory.createChar("ace"); assertTrue(a.compareTo(b) < 0); assertTrue(b.compareTo(a) > 0); assertTrue(c.compareTo(c) == 0); }