/** * Writes a list of {@link Streamable} objects */ public void writeStreamableList(List<? extends Streamable> list) throws IOException { writeVInt(list.size()); for (Streamable obj: list) { obj.writeTo(this); } }
/** * Serializes a potential null value. */ public void writeOptionalStreamable(@Nullable Streamable streamable) throws IOException { if (streamable != null) { writeBoolean(true); streamable.writeTo(this); } else { writeBoolean(false); } }
/** * Writes a list of {@link Streamable} objects */ public void writeStreamableList(List<? extends Streamable> list) throws IOException { writeVInt(list.size()); for (Streamable obj: list) { obj.writeTo(this); } }
/** * Writes a list of {@link Streamable} objects */ public void writeStreamableList(List<? extends Streamable> list) throws IOException { writeVInt(list.size()); for (Streamable obj: list) { obj.writeTo(this); } }
/** * Writes a list of {@link Writeable} objects */ public void writeList(List<? extends Writeable> list) throws IOException { writeVInt(list.size()); for (Writeable obj: list) { obj.writeTo(this); } }
/** * Serializes a potential null value. */ public void writeOptionalStreamable(@Nullable Streamable streamable) throws IOException { if (streamable != null) { writeBoolean(true); streamable.writeTo(this); } else { writeBoolean(false); } }
/** * Serializes a potential null value. */ public void writeOptionalStreamable(@Nullable Streamable streamable) throws IOException { if (streamable != null) { writeBoolean(true); streamable.writeTo(this); } else { writeBoolean(false); } }
public void writeOptionalWriteable(@Nullable Writeable writeable) throws IOException { if (writeable != null) { writeBoolean(true); writeable.writeTo(this); } else { writeBoolean(false); } }
/** * Serializes a potential null value. */ public void writeOptionalStreamable(@Nullable Streamable streamable) throws IOException { if (streamable != null) { writeBoolean(true); streamable.writeTo(this); } else { writeBoolean(false); } }
private static BytesReference serialize(Version version, Streamable streamable) throws IOException { BytesStreamOutput output = new BytesStreamOutput(); output.setVersion(version); streamable.writeTo(output); output.flush(); return output.bytes(); }
/** * Round trip {@code instance} through binary serialization, setting the wire compatibility version to {@code version}. */ private T copyInstance(T instance, Version version) throws IOException { try (BytesStreamOutput output = new BytesStreamOutput()) { output.setVersion(version); instance.writeTo(output); try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), getNamedWriteableRegistry())) { in.setVersion(version); T newInstance = createBlankInstance(); newInstance.readFrom(in); return newInstance; } } }