public void writeDelimitedTo(final OutputStream output) throws IOException {
   final int serialized = getSerializedSize();
   final int bufferSize =
       CodedOutputStream.computePreferredBufferSize(
           CodedOutputStream.computeRawVarint32Size(serialized) + serialized);
   final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize);
   codedOutput.writeRawVarint32(serialized);
   writeTo(codedOutput);
   codedOutput.flush();
 }
 public ByteString toByteString() {
   try {
     final ByteString.CodedBuilder out = ByteString.newCodedBuilder(getSerializedSize());
     writeTo(out.getCodedOutput());
     return out.build();
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a ByteString threw an IOException (should " + "never happen).", e);
   }
 }
 public byte[] toByteArray() {
   try {
     final byte[] result = new byte[getSerializedSize()];
     final CodedOutputStream output = CodedOutputStream.newInstance(result);
     writeTo(output);
     output.checkNoSpaceLeft();
     return result;
   } catch (IOException e) {
     throw new RuntimeException(
         "Serializing to a byte array threw an IOException " + "(should never happen).", e);
   }
 }
 public void writeTo(final OutputStream output) throws IOException {
   final int bufferSize = CodedOutputStream.computePreferredBufferSize(getSerializedSize());
   final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize);
   writeTo(codedOutput);
   codedOutput.flush();
 }