Beispiel #1
0
  @Override
  public Pair<A, B> decode(byte[] data) {

    byte[][] fields = split(data);
    if (fields.length != 2) {
      throw new RuntimeException("Data does not have 2 fields, it has " + fields.length);
    }

    return new Pair<A, B>(
        firstLexicoder.decode(unescape(fields[0])), secondLexicoder.decode(unescape(fields[1])));
  }
Beispiel #2
0
 @Override
 public byte[] encode(Pair<A, B> data) {
   return concat(
       escape(firstLexicoder.encode(data.getFirst())),
       escape(secondLexicoder.encode(data.getSecond())));
 }