Java Code Examples for com.google.protobuf.MessageLite#toByteString()

The following examples show how to use com.google.protobuf.MessageLite#toByteString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyClusterMessage.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public MyClusterMessage(IMHeader header, MessageLite message) {
    this.setLength(header.getLength());
    this.setServiceId(header.getServiceId());
    this.setCommandId(header.getCommandId());
    this.setFlag(header.getFlag());
    this.setSeqnum(header.getSeqnum());
    this.setVersion(header.getVersion());
    this.setReserved(header.getReserved());
    this.body = message.toByteString();
}
 
Example 2
Source File: CompatibilityTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testMessageLite() throws Exception {
  // Mainly a compilation test for the Lite classes.
  MessageLite.Builder builder = TypicalData.newBuilder();
  MessageLite message = builder.build();
  assertTrue(message instanceof MessageLite);
  message.toByteString();
}
 
Example 3
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T extends MessageLite> T convert(MessageLite m, T.Builder builder) {
  ByteString data = m.toByteString();
  builder.clear();

  try {
    builder.mergeFrom(data);
  } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException(e);
  }

  return (T) builder.build();
}
 
Example 4
Source File: MinorDataSerDe.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public ByteString serialize(MessageLite msg) {
  return msg.toByteString();
}