@Override
  public int encode(PositionedByteRange dst, T val) {
    final int start = dst.getPosition();
    int written = wrapped.encode(dst, val);
    PositionedByteRange b = dst.shallowCopy();
    b.setLength(dst.getPosition());
    b.setPosition(start);
    if (-1 != terminatorPosition(b)) {
      dst.setPosition(start);
      throw new IllegalArgumentException("Encoded value contains terminator sequence.");
    }
    dst.put(term);
    return written + term.length;
  }
Write instance {@code val} into buffer {@code dst}.
@throws IllegalArgumentException when the encoded representation of {@code val} contains the
                                 {@code term} sequence.
hbase-common/src/main/java/org/apache/hadoop/hbase/types/TerminatedWrapper.java