Beispiel #1
0
  @Override
  public void write(DataOutput out) throws IOException {
    // Serialize class names of each non-null field
    final ClassIndex index = new ClassIndex();

    if (fst != null) index.addClass(fst.getClass());
    if (snd != null) index.addClass(snd.getClass());
    index.write(out);

    // Indicate which fields are null
    out.writeByte((fst == null ? FST_NULL : NOT_NULL) | (snd == null ? SND_NULL : NOT_NULL));

    // Serialize each non-null field
    if (fst != null) {
      out.writeByte(index.getId(fst.getClass()));
      fst.write(out);
    }
    if (snd != null) {
      out.writeByte(index.getId(snd.getClass()));
      snd.write(out);
    }
  }
Beispiel #2
0
 @Override
 public void write(DataOutput dataOutput) throws IOException {
   first.write(dataOutput);
   second.write(dataOutput);
 }