18 changed files with 1719 additions and 22 deletions
@ -0,0 +1,324 @@
@@ -0,0 +1,324 @@
|
||||
/* |
||||
* Copyright 2002-2019 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.messaging.converter; |
||||
|
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.OutputStream; |
||||
import java.io.OutputStreamWriter; |
||||
import java.lang.reflect.Method; |
||||
import java.nio.charset.Charset; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.Arrays; |
||||
import java.util.Map; |
||||
|
||||
import com.google.protobuf.ExtensionRegistry; |
||||
import com.google.protobuf.Message; |
||||
import com.google.protobuf.util.JsonFormat; |
||||
import org.springframework.lang.Nullable; |
||||
import org.springframework.messaging.MessageHeaders; |
||||
import org.springframework.util.ClassUtils; |
||||
import org.springframework.util.ConcurrentReferenceHashMap; |
||||
import org.springframework.util.MimeType; |
||||
|
||||
import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON; |
||||
import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN; |
||||
|
||||
/** |
||||
* An {@code MessageConverter} that reads and writes |
||||
* {@link com.google.protobuf.Message com.google.protobuf.Messages} using |
||||
* <a href="https://developers.google.com/protocol-buffers/">Google Protocol Buffers</a>. |
||||
* |
||||
* <p>To generate {@code Message} Java classes, you need to install the {@code protoc} binary. |
||||
* |
||||
* <p>This converter supports by default {@code "application/x-protobuf"} with the official |
||||
* {@code "com.google.protobuf:protobuf-java"} library. |
||||
* |
||||
* <p>{@code "application/json"} can be supported with the official {@code "com.google.protobuf:protobuf-java-util"} 3.x |
||||
* with 3.3 or higher recommended |
||||
* |
||||
* @author Parviz Rozikov |
||||
* @since 5.2.2 |
||||
*/ |
||||
public class ProtobufMessageConverter extends AbstractMessageConverter { |
||||
|
||||
|
||||
/** |
||||
* The default charset used by the converter. |
||||
*/ |
||||
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; |
||||
|
||||
/** |
||||
* The mime-type for protobuf {@code application/x-protobuf}. |
||||
*/ |
||||
public static final MimeType PROTOBUF = new MimeType("application", "x-protobuf", DEFAULT_CHARSET); |
||||
|
||||
|
||||
private static final Map<Class<?>, Method> methodCache = new ConcurrentReferenceHashMap<>(); |
||||
|
||||
final ExtensionRegistry extensionRegistry; |
||||
|
||||
@Nullable |
||||
private final ProtobufFormatSupport protobufFormatSupport; |
||||
|
||||
|
||||
/** |
||||
* Construct a new {@code ProtobufMessageConverter}. |
||||
*/ |
||||
public ProtobufMessageConverter() { |
||||
this((ProtobufFormatSupport) null, (ExtensionRegistry) null); |
||||
} |
||||
|
||||
/** |
||||
* Construct a new {@code ProtobufMessageConverter} with a registry that specifies |
||||
* protocol message extensions. |
||||
* |
||||
* @param extensionRegistry the registry to populate |
||||
*/ |
||||
public ProtobufMessageConverter(@Nullable ExtensionRegistry extensionRegistry) { |
||||
this(null, extensionRegistry); |
||||
} |
||||
|
||||
/** |
||||
* Construct a new {@code ProtobufMessageConverter} with the given |
||||
* {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration. |
||||
* |
||||
* @param parser the JSON parser configuration |
||||
* @param printer the JSON printer configuration |
||||
*/ |
||||
public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { |
||||
this(new ProtobufJavaUtilSupport(parser, printer), (ExtensionRegistry) null); |
||||
} |
||||
|
||||
/** |
||||
* Construct a new {@code ProtobufMessageConverter} with the given |
||||
* {@code JsonFormat.Parser} and {@code JsonFormat.Printer} configuration, also |
||||
* accepting a registry that specifies protocol message extensions. |
||||
* |
||||
* @param parser the JSON parser configuration |
||||
* @param printer the JSON printer configuration |
||||
* @param extensionRegistry the registry to populate |
||||
*/ |
||||
public ProtobufMessageConverter(@Nullable JsonFormat.Parser parser, |
||||
@Nullable JsonFormat.Printer printer, @Nullable ExtensionRegistry extensionRegistry) { |
||||
|
||||
this(new ProtobufJavaUtilSupport(parser, printer), extensionRegistry); |
||||
} |
||||
|
||||
/** |
||||
* Construct a new {@code ProtobufMessageConverter} with the given |
||||
* {@code ProtobufFormatSupport} configuration, also |
||||
* accepting a registry that specifies protocol message extensions. |
||||
* |
||||
* @param formatSupport support third party |
||||
* @param extensionRegistry the registry to populate |
||||
*/ |
||||
public ProtobufMessageConverter(@Nullable ProtobufFormatSupport formatSupport, |
||||
@Nullable ExtensionRegistry extensionRegistry) { |
||||
super(PROTOBUF); |
||||
|
||||
if (formatSupport != null) { |
||||
this.protobufFormatSupport = formatSupport; |
||||
} |
||||
else if (ClassUtils.isPresent("com.google.protobuf.util.JsonFormat", getClass().getClassLoader())) { |
||||
this.protobufFormatSupport = new ProtobufJavaUtilSupport(null, null); |
||||
} |
||||
else { |
||||
this.protobufFormatSupport = null; |
||||
} |
||||
|
||||
if (this.protobufFormatSupport != null) { |
||||
setSupportedMimeTypes(Arrays.asList(protobufFormatSupport.supportedMediaTypes())); |
||||
} |
||||
|
||||
this.extensionRegistry = (extensionRegistry == null ? ExtensionRegistry.newInstance() : extensionRegistry); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean supports(Class<?> clazz) { |
||||
return Message.class.isAssignableFrom(clazz); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean canConvertTo(Object payload, @Nullable MessageHeaders headers) { |
||||
MimeType mimeType = getMimeType(headers); |
||||
return (super.canConvertTo(payload, headers) || |
||||
this.protobufFormatSupport != null && this.protobufFormatSupport.supportsWriteOnly(mimeType)); |
||||
} |
||||
|
||||
@Override |
||||
protected Object convertFromInternal(org.springframework.messaging.Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) { |
||||
MimeType contentType = getMimeType(message.getHeaders()); |
||||
final Object payload = message.getPayload(); |
||||
|
||||
if (contentType == null) { |
||||
contentType = PROTOBUF; |
||||
} |
||||
|
||||
Charset charset = contentType.getCharset(); |
||||
if (charset == null) { |
||||
charset = DEFAULT_CHARSET; |
||||
} |
||||
|
||||
Message.Builder builder = getMessageBuilder(targetClass); |
||||
|
||||
try { |
||||
if (PROTOBUF.isCompatibleWith(contentType)) { |
||||
builder.mergeFrom((byte[]) payload, this.extensionRegistry); |
||||
} |
||||
else if (protobufFormatSupport != null) { |
||||
this.protobufFormatSupport.merge( |
||||
message, charset, contentType, this.extensionRegistry, builder); |
||||
} |
||||
} |
||||
catch (IOException e) { |
||||
throw new MessageConversionException(message, "Could not read proto message" + e.getMessage(), e); |
||||
} |
||||
|
||||
return builder.build(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { |
||||
final Message message = (Message) payload; |
||||
|
||||
MimeType contentType = getMimeType(headers); |
||||
if (contentType == null) { |
||||
contentType = PROTOBUF; |
||||
|
||||
} |
||||
|
||||
Charset charset = contentType.getCharset(); |
||||
if (charset == null) { |
||||
charset = DEFAULT_CHARSET; |
||||
} |
||||
|
||||
try { |
||||
if (PROTOBUF.isCompatibleWith(contentType)) { |
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
||||
message.writeTo(byteArrayOutputStream); |
||||
payload = byteArrayOutputStream.toByteArray(); |
||||
} |
||||
else if (this.protobufFormatSupport != null) { |
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
||||
this.protobufFormatSupport.print(message, outputStream, contentType, charset); |
||||
payload = new String(outputStream.toByteArray(), charset); |
||||
} |
||||
} |
||||
catch (IOException e) { |
||||
throw new MessageConversionException("Could not write proto message" + e.getMessage(), e); |
||||
|
||||
} |
||||
return payload; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Create a new {@code Message.Builder} instance for the given class. |
||||
* <p>This method uses a ConcurrentReferenceHashMap for caching method lookups. |
||||
*/ |
||||
private Message.Builder getMessageBuilder(Class<?> clazz) { |
||||
try { |
||||
Method method = methodCache.get(clazz); |
||||
if (method == null) { |
||||
method = clazz.getMethod("newBuilder"); |
||||
methodCache.put(clazz, method); |
||||
} |
||||
return (Message.Builder) method.invoke(clazz); |
||||
} |
||||
catch (Exception ex) { |
||||
throw new MessageConversionException( |
||||
"Invalid Protobuf Message type: no invocable newBuilder() method on " + clazz, ex); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Protobuf format support. |
||||
*/ |
||||
interface ProtobufFormatSupport { |
||||
|
||||
MimeType[] supportedMediaTypes(); |
||||
|
||||
boolean supportsWriteOnly(@Nullable MimeType mediaType); |
||||
|
||||
void merge(org.springframework.messaging.Message<?> message, Charset charset, MimeType contentType, |
||||
ExtensionRegistry extensionRegistry, Message.Builder builder) |
||||
throws IOException, MessageConversionException; |
||||
|
||||
void print(Message message, OutputStream output, MimeType contentType, Charset charset) |
||||
throws IOException, MessageConversionException; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* {@link ProtobufFormatSupport} implementation used when |
||||
* {@code com.google.protobuf.util.JsonFormat} is available. |
||||
*/ |
||||
static class ProtobufJavaUtilSupport implements ProtobufFormatSupport { |
||||
|
||||
private final JsonFormat.Parser parser; |
||||
|
||||
private final JsonFormat.Printer printer; |
||||
|
||||
public ProtobufJavaUtilSupport(@Nullable JsonFormat.Parser parser, @Nullable JsonFormat.Printer printer) { |
||||
this.parser = (parser != null ? parser : JsonFormat.parser()); |
||||
this.printer = (printer != null ? printer : JsonFormat.printer()); |
||||
} |
||||
|
||||
@Override |
||||
public MimeType[] supportedMediaTypes() { |
||||
return new MimeType[]{PROTOBUF, TEXT_PLAIN, APPLICATION_JSON}; |
||||
} |
||||
|
||||
@Override |
||||
public boolean supportsWriteOnly(@Nullable MimeType mimeType) { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void merge(org.springframework.messaging.Message<?> message, Charset charset, MimeType contentType, |
||||
ExtensionRegistry extensionRegistry, Message.Builder builder) |
||||
throws IOException, MessageConversionException { |
||||
|
||||
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
||||
this.parser.merge(message.getPayload().toString(), builder); |
||||
} |
||||
else { |
||||
throw new MessageConversionException( |
||||
"protobuf-java-util does not support parsing " + contentType); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void print(Message message, OutputStream output, MimeType contentType, Charset charset) |
||||
throws IOException, MessageConversionException { |
||||
|
||||
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
||||
OutputStreamWriter writer = new OutputStreamWriter(output, charset); |
||||
this.printer.appendTo(message, writer); |
||||
writer.flush(); |
||||
} else { |
||||
throw new MessageConversionException( |
||||
"protobuf-java-util does not support printing " + contentType); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,142 @@
@@ -0,0 +1,142 @@
|
||||
/* |
||||
* Copyright 2002-2019 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.messaging.converter; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import com.google.protobuf.ExtensionRegistry; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.springframework.messaging.Message; |
||||
import org.springframework.messaging.MessageHeaders; |
||||
import org.springframework.messaging.protobuf.Msg; |
||||
import org.springframework.messaging.protobuf.SecondMsg; |
||||
import org.springframework.messaging.support.MessageBuilder; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
import static org.mockito.Mockito.mock; |
||||
import static org.springframework.messaging.MessageHeaders.CONTENT_TYPE; |
||||
import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON; |
||||
|
||||
/** |
||||
* Test suite for {@link ProtobufMessageConverter}. |
||||
* |
||||
* @author Parviz Rozikov |
||||
*/ |
||||
class ProtobufMessageConverterTest { |
||||
|
||||
private ProtobufMessageConverter converter; |
||||
|
||||
private ExtensionRegistry extensionRegistry; |
||||
|
||||
private Msg testMsg; |
||||
private Message<byte[]> message; |
||||
private Message<byte[]> messageWithoutContentType; |
||||
private Message<String> messageJson; |
||||
|
||||
|
||||
@BeforeEach |
||||
public void setup() { |
||||
this.extensionRegistry = mock(ExtensionRegistry.class); |
||||
this.converter = new ProtobufMessageConverter(); |
||||
this.testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build(); |
||||
this.message = MessageBuilder.withPayload(this.testMsg.toByteArray()) |
||||
.setHeader(CONTENT_TYPE, ProtobufMessageConverter.PROTOBUF).build(); |
||||
this.messageWithoutContentType = MessageBuilder.withPayload(this.testMsg.toByteArray()) |
||||
.build(); |
||||
this.messageJson = MessageBuilder.withPayload("{\n" + |
||||
" \"foo\": \"Foo\",\n" + |
||||
" \"blah\": {\n" + |
||||
" \"blah\": 123\n" + |
||||
" }\n" + |
||||
"}") |
||||
.setHeader(CONTENT_TYPE, APPLICATION_JSON).build(); |
||||
} |
||||
|
||||
@Test |
||||
public void extensionRegistryNull() { |
||||
ProtobufMessageConverter converter = new ProtobufMessageConverter((ExtensionRegistry) null); |
||||
assertThat(converter.extensionRegistry).isNotNull(); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void canConvertFrom() { |
||||
assertThat(converter.canConvertFrom(message, Msg.class)).isTrue(); |
||||
assertThat(converter.canConvertFrom(messageWithoutContentType, Msg.class)).isTrue(); |
||||
assertThat(converter.canConvertFrom(messageJson, Msg.class)).isTrue(); |
||||
} |
||||
|
||||
@Test |
||||
public void canConvertTo() { |
||||
assertThat(converter.canConvertTo(testMsg, message.getHeaders())).isTrue(); |
||||
assertThat(converter.canConvertTo(testMsg, messageWithoutContentType.getHeaders())).isTrue(); |
||||
assertThat(converter.canConvertTo(testMsg, messageJson.getHeaders())).isTrue(); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void convertFrom() throws IOException { |
||||
final Msg msg = (Msg) converter.fromMessage(message, Msg.class); |
||||
assertThat(msg).isEqualTo(testMsg); |
||||
} |
||||
|
||||
@Test |
||||
public void convertTo() throws IOException { |
||||
final Message<?> message = converter.toMessage(this.testMsg, this.message.getHeaders()); |
||||
assertThat(message).isNotNull(); |
||||
assertThat(message.getPayload()).isEqualTo(this.message.getPayload()); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void convertFromNoContentType() throws IOException { |
||||
Msg result = (Msg) converter.fromMessage(messageWithoutContentType, Msg.class); |
||||
assertThat(result).isEqualTo(testMsg); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void defaultContentType() throws Exception { |
||||
assertThat(converter.getDefaultContentType(testMsg)).isEqualTo(ProtobufMessageConverter.PROTOBUF); |
||||
} |
||||
|
||||
@Test |
||||
public void testJsonWithGoogleProtobuf() throws Exception { |
||||
this.converter = new ProtobufMessageConverter( |
||||
new ProtobufMessageConverter.ProtobufJavaUtilSupport(null, null), |
||||
extensionRegistry); |
||||
|
||||
final Map<String, Object> headers = new HashMap<>(); |
||||
headers.put(CONTENT_TYPE, APPLICATION_JSON); |
||||
|
||||
//convertTo
|
||||
final Message<?> message = this.converter.toMessage(this.testMsg, new MessageHeaders(headers)); |
||||
assertThat(message).isNotNull(); |
||||
assertThat(message.getHeaders().get(CONTENT_TYPE)).isEqualTo(APPLICATION_JSON); |
||||
assertThat(((String) message.getPayload()).length() > 0).isTrue(); |
||||
assertThat(((String) message.getPayload()).isEmpty()).as("Body is empty").isFalse(); |
||||
assertThat(((String) message.getPayload())).isEqualTo(this.messageJson.getPayload()); |
||||
|
||||
//convertFrom
|
||||
final Msg msg = (Msg) converter.fromMessage(message, Msg.class); |
||||
assertThat(msg).isEqualTo(this.testMsg); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,654 @@
@@ -0,0 +1,654 @@
|
||||
/* |
||||
* Copyright 2002-2016 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: sample.proto
|
||||
|
||||
package org.springframework.messaging.protobuf; |
||||
|
||||
/** |
||||
* Protobuf type {@code Msg} |
||||
*/ |
||||
public final class Msg extends |
||||
com.google.protobuf.GeneratedMessage |
||||
implements MsgOrBuilder { |
||||
// Use Msg.newBuilder() to construct.
|
||||
private Msg(com.google.protobuf.GeneratedMessage.Builder<?> builder) { |
||||
super(builder); |
||||
this.unknownFields = builder.getUnknownFields(); |
||||
} |
||||
private Msg(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } |
||||
|
||||
private static final Msg defaultInstance; |
||||
public static Msg getDefaultInstance() { |
||||
return defaultInstance; |
||||
} |
||||
|
||||
public Msg getDefaultInstanceForType() { |
||||
return defaultInstance; |
||||
} |
||||
|
||||
private final com.google.protobuf.UnknownFieldSet unknownFields; |
||||
@java.lang.Override |
||||
public final com.google.protobuf.UnknownFieldSet |
||||
getUnknownFields() { |
||||
return this.unknownFields; |
||||
} |
||||
private Msg( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
initFields(); |
||||
@SuppressWarnings("unused") |
||||
int mutable_bitField0_ = 0; |
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields = |
||||
com.google.protobuf.UnknownFieldSet.newBuilder(); |
||||
try { |
||||
boolean done = false; |
||||
while (!done) { |
||||
int tag = input.readTag(); |
||||
switch (tag) { |
||||
case 0: |
||||
done = true; |
||||
break; |
||||
default: { |
||||
if (!parseUnknownField(input, unknownFields, |
||||
extensionRegistry, tag)) { |
||||
done = true; |
||||
} |
||||
break; |
||||
} |
||||
case 10: { |
||||
bitField0_ |= 0x00000001; |
||||
foo_ = input.readBytes(); |
||||
break; |
||||
} |
||||
case 18: { |
||||
SecondMsg.Builder subBuilder = null; |
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) { |
||||
subBuilder = blah_.toBuilder(); |
||||
} |
||||
blah_ = input.readMessage(SecondMsg.PARSER, extensionRegistry); |
||||
if (subBuilder != null) { |
||||
subBuilder.mergeFrom(blah_); |
||||
blah_ = subBuilder.buildPartial(); |
||||
} |
||||
bitField0_ |= 0x00000002; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) { |
||||
throw e.setUnfinishedMessage(this); |
||||
} catch (java.io.IOException e) { |
||||
throw new com.google.protobuf.InvalidProtocolBufferException( |
||||
e.getMessage()).setUnfinishedMessage(this); |
||||
} finally { |
||||
this.unknownFields = unknownFields.build(); |
||||
makeExtensionsImmutable(); |
||||
} |
||||
} |
||||
public static final com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptor() { |
||||
return OuterSample.internal_static_Msg_descriptor; |
||||
} |
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internalGetFieldAccessorTable() { |
||||
return OuterSample.internal_static_Msg_fieldAccessorTable |
||||
.ensureFieldAccessorsInitialized( |
||||
Msg.class, Msg.Builder.class); |
||||
} |
||||
|
||||
public static com.google.protobuf.Parser<Msg> PARSER = |
||||
new com.google.protobuf.AbstractParser<Msg>() { |
||||
public Msg parsePartialFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return new Msg(input, extensionRegistry); |
||||
} |
||||
}; |
||||
|
||||
@java.lang.Override |
||||
public com.google.protobuf.Parser<Msg> getParserForType() { |
||||
return PARSER; |
||||
} |
||||
|
||||
private int bitField0_; |
||||
// optional string foo = 1;
|
||||
public static final int FOO_FIELD_NUMBER = 1; |
||||
private java.lang.Object foo_; |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public boolean hasFoo() { |
||||
return ((bitField0_ & 0x00000001) == 0x00000001); |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public java.lang.String getFoo() { |
||||
java.lang.Object ref = foo_; |
||||
if (ref instanceof java.lang.String) { |
||||
return (java.lang.String) ref; |
||||
} else { |
||||
com.google.protobuf.ByteString bs = |
||||
(com.google.protobuf.ByteString) ref; |
||||
java.lang.String s = bs.toStringUtf8(); |
||||
if (bs.isValidUtf8()) { |
||||
foo_ = s; |
||||
} |
||||
return s; |
||||
} |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public com.google.protobuf.ByteString |
||||
getFooBytes() { |
||||
java.lang.Object ref = foo_; |
||||
if (ref instanceof java.lang.String) { |
||||
com.google.protobuf.ByteString b = |
||||
com.google.protobuf.ByteString.copyFromUtf8( |
||||
(java.lang.String) ref); |
||||
foo_ = b; |
||||
return b; |
||||
} else { |
||||
return (com.google.protobuf.ByteString) ref; |
||||
} |
||||
} |
||||
|
||||
// optional .SecondMsg blah = 2;
|
||||
public static final int BLAH_FIELD_NUMBER = 2; |
||||
private SecondMsg blah_; |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public boolean hasBlah() { |
||||
return ((bitField0_ & 0x00000002) == 0x00000002); |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public SecondMsg getBlah() { |
||||
return blah_; |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public SecondMsgOrBuilder getBlahOrBuilder() { |
||||
return blah_; |
||||
} |
||||
|
||||
private void initFields() { |
||||
foo_ = ""; |
||||
blah_ = SecondMsg.getDefaultInstance(); |
||||
} |
||||
private byte memoizedIsInitialized = -1; |
||||
public final boolean isInitialized() { |
||||
byte isInitialized = memoizedIsInitialized; |
||||
if (isInitialized != -1) return isInitialized == 1; |
||||
|
||||
memoizedIsInitialized = 1; |
||||
return true; |
||||
} |
||||
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output) |
||||
throws java.io.IOException { |
||||
getSerializedSize(); |
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) { |
||||
output.writeBytes(1, getFooBytes()); |
||||
} |
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) { |
||||
output.writeMessage(2, blah_); |
||||
} |
||||
getUnknownFields().writeTo(output); |
||||
} |
||||
|
||||
private int memoizedSerializedSize = -1; |
||||
public int getSerializedSize() { |
||||
int size = memoizedSerializedSize; |
||||
if (size != -1) return size; |
||||
|
||||
size = 0; |
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) { |
||||
size += com.google.protobuf.CodedOutputStream |
||||
.computeBytesSize(1, getFooBytes()); |
||||
} |
||||
if (((bitField0_ & 0x00000002) == 0x00000002)) { |
||||
size += com.google.protobuf.CodedOutputStream |
||||
.computeMessageSize(2, blah_); |
||||
} |
||||
size += getUnknownFields().getSerializedSize(); |
||||
memoizedSerializedSize = size; |
||||
return size; |
||||
} |
||||
|
||||
private static final long serialVersionUID = 0L; |
||||
@java.lang.Override |
||||
protected java.lang.Object writeReplace() |
||||
throws java.io.ObjectStreamException { |
||||
return super.writeReplace(); |
||||
} |
||||
|
||||
public static Msg parseFrom( |
||||
com.google.protobuf.ByteString data) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data); |
||||
} |
||||
public static Msg parseFrom( |
||||
com.google.protobuf.ByteString data, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data, extensionRegistry); |
||||
} |
||||
public static Msg parseFrom(byte[] data) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data); |
||||
} |
||||
public static Msg parseFrom( |
||||
byte[] data, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data, extensionRegistry); |
||||
} |
||||
public static Msg parseFrom(java.io.InputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input); |
||||
} |
||||
public static Msg parseFrom( |
||||
java.io.InputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input, extensionRegistry); |
||||
} |
||||
public static Msg parseDelimitedFrom(java.io.InputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseDelimitedFrom(input); |
||||
} |
||||
public static Msg parseDelimitedFrom( |
||||
java.io.InputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry); |
||||
} |
||||
public static Msg parseFrom( |
||||
com.google.protobuf.CodedInputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input); |
||||
} |
||||
public static Msg parseFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input, extensionRegistry); |
||||
} |
||||
|
||||
public static Builder newBuilder() { return Builder.create(); } |
||||
public Builder newBuilderForType() { return newBuilder(); } |
||||
public static Builder newBuilder(Msg prototype) { |
||||
return newBuilder().mergeFrom(prototype); |
||||
} |
||||
public Builder toBuilder() { return newBuilder(this); } |
||||
|
||||
@java.lang.Override |
||||
protected Builder newBuilderForType( |
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) { |
||||
Builder builder = new Builder(parent); |
||||
return builder; |
||||
} |
||||
/** |
||||
* Protobuf type {@code Msg} |
||||
*/ |
||||
public static final class Builder extends |
||||
com.google.protobuf.GeneratedMessage.Builder<Builder> |
||||
implements MsgOrBuilder { |
||||
public static final com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptor() { |
||||
return OuterSample.internal_static_Msg_descriptor; |
||||
} |
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internalGetFieldAccessorTable() { |
||||
return OuterSample.internal_static_Msg_fieldAccessorTable |
||||
.ensureFieldAccessorsInitialized( |
||||
Msg.class, Msg.Builder.class); |
||||
} |
||||
|
||||
// Construct using org.springframework.messaging.protobuf.Msg.newBuilder()
|
||||
private Builder() { |
||||
maybeForceBuilderInitialization(); |
||||
} |
||||
|
||||
private Builder( |
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) { |
||||
super(parent); |
||||
maybeForceBuilderInitialization(); |
||||
} |
||||
private void maybeForceBuilderInitialization() { |
||||
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { |
||||
getBlahFieldBuilder(); |
||||
} |
||||
} |
||||
private static Builder create() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
public Builder clear() { |
||||
super.clear(); |
||||
foo_ = ""; |
||||
bitField0_ = (bitField0_ & ~0x00000001); |
||||
if (blahBuilder_ == null) { |
||||
blah_ = SecondMsg.getDefaultInstance(); |
||||
} else { |
||||
blahBuilder_.clear(); |
||||
} |
||||
bitField0_ = (bitField0_ & ~0x00000002); |
||||
return this; |
||||
} |
||||
|
||||
public Builder clone() { |
||||
return create().mergeFrom(buildPartial()); |
||||
} |
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptorForType() { |
||||
return OuterSample.internal_static_Msg_descriptor; |
||||
} |
||||
|
||||
public Msg getDefaultInstanceForType() { |
||||
return Msg.getDefaultInstance(); |
||||
} |
||||
|
||||
public Msg build() { |
||||
Msg result = buildPartial(); |
||||
if (!result.isInitialized()) { |
||||
throw newUninitializedMessageException(result); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public Msg buildPartial() { |
||||
Msg result = new Msg(this); |
||||
int from_bitField0_ = bitField0_; |
||||
int to_bitField0_ = 0; |
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) { |
||||
to_bitField0_ |= 0x00000001; |
||||
} |
||||
result.foo_ = foo_; |
||||
if (((from_bitField0_ & 0x00000002) == 0x00000002)) { |
||||
to_bitField0_ |= 0x00000002; |
||||
} |
||||
if (blahBuilder_ == null) { |
||||
result.blah_ = blah_; |
||||
} else { |
||||
result.blah_ = blahBuilder_.build(); |
||||
} |
||||
result.bitField0_ = to_bitField0_; |
||||
onBuilt(); |
||||
return result; |
||||
} |
||||
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) { |
||||
if (other instanceof Msg) { |
||||
return mergeFrom((Msg)other); |
||||
} else { |
||||
super.mergeFrom(other); |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public Builder mergeFrom(Msg other) { |
||||
if (other == Msg.getDefaultInstance()) return this; |
||||
if (other.hasFoo()) { |
||||
bitField0_ |= 0x00000001; |
||||
foo_ = other.foo_; |
||||
onChanged(); |
||||
} |
||||
if (other.hasBlah()) { |
||||
mergeBlah(other.getBlah()); |
||||
} |
||||
this.mergeUnknownFields(other.getUnknownFields()); |
||||
return this; |
||||
} |
||||
|
||||
public final boolean isInitialized() { |
||||
return true; |
||||
} |
||||
|
||||
public Builder mergeFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
Msg parsedMessage = null; |
||||
try { |
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); |
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) { |
||||
parsedMessage = (Msg) e.getUnfinishedMessage(); |
||||
throw e; |
||||
} finally { |
||||
if (parsedMessage != null) { |
||||
mergeFrom(parsedMessage); |
||||
} |
||||
} |
||||
return this; |
||||
} |
||||
private int bitField0_; |
||||
|
||||
// optional string foo = 1;
|
||||
private java.lang.Object foo_ = ""; |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public boolean hasFoo() { |
||||
return ((bitField0_ & 0x00000001) == 0x00000001); |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public java.lang.String getFoo() { |
||||
java.lang.Object ref = foo_; |
||||
if (!(ref instanceof java.lang.String)) { |
||||
java.lang.String s = ((com.google.protobuf.ByteString) ref) |
||||
.toStringUtf8(); |
||||
foo_ = s; |
||||
return s; |
||||
} else { |
||||
return (java.lang.String) ref; |
||||
} |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public com.google.protobuf.ByteString |
||||
getFooBytes() { |
||||
java.lang.Object ref = foo_; |
||||
if (ref instanceof String) { |
||||
com.google.protobuf.ByteString b = |
||||
com.google.protobuf.ByteString.copyFromUtf8( |
||||
(java.lang.String) ref); |
||||
foo_ = b; |
||||
return b; |
||||
} else { |
||||
return (com.google.protobuf.ByteString) ref; |
||||
} |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public Builder setFoo( |
||||
java.lang.String value) { |
||||
if (value == null) { |
||||
throw new NullPointerException(); |
||||
} |
||||
bitField0_ |= 0x00000001; |
||||
foo_ = value; |
||||
onChanged(); |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public Builder clearFoo() { |
||||
bitField0_ = (bitField0_ & ~0x00000001); |
||||
foo_ = getDefaultInstance().getFoo(); |
||||
onChanged(); |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
public Builder setFooBytes( |
||||
com.google.protobuf.ByteString value) { |
||||
if (value == null) { |
||||
throw new NullPointerException(); |
||||
} |
||||
bitField0_ |= 0x00000001; |
||||
foo_ = value; |
||||
onChanged(); |
||||
return this; |
||||
} |
||||
|
||||
// optional .SecondMsg blah = 2;
|
||||
private SecondMsg blah_ = SecondMsg.getDefaultInstance(); |
||||
private com.google.protobuf.SingleFieldBuilder< |
||||
SecondMsg, SecondMsg.Builder, |
||||
SecondMsgOrBuilder> blahBuilder_; |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public boolean hasBlah() { |
||||
return ((bitField0_ & 0x00000002) == 0x00000002); |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public SecondMsg getBlah() { |
||||
if (blahBuilder_ == null) { |
||||
return blah_; |
||||
} else { |
||||
return blahBuilder_.getMessage(); |
||||
} |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public Builder setBlah(SecondMsg value) { |
||||
if (blahBuilder_ == null) { |
||||
if (value == null) { |
||||
throw new NullPointerException(); |
||||
} |
||||
blah_ = value; |
||||
onChanged(); |
||||
} else { |
||||
blahBuilder_.setMessage(value); |
||||
} |
||||
bitField0_ |= 0x00000002; |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public Builder setBlah( |
||||
SecondMsg.Builder builderForValue) { |
||||
if (blahBuilder_ == null) { |
||||
blah_ = builderForValue.build(); |
||||
onChanged(); |
||||
} else { |
||||
blahBuilder_.setMessage(builderForValue.build()); |
||||
} |
||||
bitField0_ |= 0x00000002; |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public Builder mergeBlah(SecondMsg value) { |
||||
if (blahBuilder_ == null) { |
||||
if (((bitField0_ & 0x00000002) == 0x00000002) && |
||||
blah_ != SecondMsg.getDefaultInstance()) { |
||||
blah_ = |
||||
SecondMsg.newBuilder(blah_).mergeFrom(value).buildPartial(); |
||||
} else { |
||||
blah_ = value; |
||||
} |
||||
onChanged(); |
||||
} else { |
||||
blahBuilder_.mergeFrom(value); |
||||
} |
||||
bitField0_ |= 0x00000002; |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public Builder clearBlah() { |
||||
if (blahBuilder_ == null) { |
||||
blah_ = SecondMsg.getDefaultInstance(); |
||||
onChanged(); |
||||
} else { |
||||
blahBuilder_.clear(); |
||||
} |
||||
bitField0_ = (bitField0_ & ~0x00000002); |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public SecondMsg.Builder getBlahBuilder() { |
||||
bitField0_ |= 0x00000002; |
||||
onChanged(); |
||||
return getBlahFieldBuilder().getBuilder(); |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
public SecondMsgOrBuilder getBlahOrBuilder() { |
||||
if (blahBuilder_ != null) { |
||||
return blahBuilder_.getMessageOrBuilder(); |
||||
} else { |
||||
return blah_; |
||||
} |
||||
} |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
private com.google.protobuf.SingleFieldBuilder< |
||||
SecondMsg, SecondMsg.Builder, |
||||
SecondMsgOrBuilder> |
||||
getBlahFieldBuilder() { |
||||
if (blahBuilder_ == null) { |
||||
blahBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( |
||||
blah_, |
||||
getParentForChildren(), |
||||
isClean()); |
||||
blah_ = null; |
||||
} |
||||
return blahBuilder_; |
||||
} |
||||
|
||||
// @@protoc_insertion_point(builder_scope:Msg)
|
||||
} |
||||
|
||||
static { |
||||
defaultInstance = new Msg(true); |
||||
defaultInstance.initFields(); |
||||
} |
||||
|
||||
// @@protoc_insertion_point(class_scope:Msg)
|
||||
} |
||||
|
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: sample.proto
|
||||
|
||||
package org.springframework.messaging.protobuf; |
||||
|
||||
public interface MsgOrBuilder |
||||
extends com.google.protobuf.MessageOrBuilder { |
||||
|
||||
// optional string foo = 1;
|
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
boolean hasFoo(); |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
java.lang.String getFoo(); |
||||
/** |
||||
* <code>optional string foo = 1;</code> |
||||
*/ |
||||
com.google.protobuf.ByteString |
||||
getFooBytes(); |
||||
|
||||
// optional .SecondMsg blah = 2;
|
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
boolean hasBlah(); |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
SecondMsg getBlah(); |
||||
/** |
||||
* <code>optional .SecondMsg blah = 2;</code> |
||||
*/ |
||||
SecondMsgOrBuilder getBlahOrBuilder(); |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: sample.proto
|
||||
|
||||
package org.springframework.messaging.protobuf; |
||||
|
||||
@SuppressWarnings("deprecation") |
||||
public class OuterSample { |
||||
private OuterSample() {} |
||||
public static void registerAllExtensions( |
||||
com.google.protobuf.ExtensionRegistry registry) { |
||||
} |
||||
static com.google.protobuf.Descriptors.Descriptor |
||||
internal_static_Msg_descriptor; |
||||
static |
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internal_static_Msg_fieldAccessorTable; |
||||
static com.google.protobuf.Descriptors.Descriptor |
||||
internal_static_SecondMsg_descriptor; |
||||
static |
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internal_static_SecondMsg_fieldAccessorTable; |
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor |
||||
getDescriptor() { |
||||
return descriptor; |
||||
} |
||||
private static com.google.protobuf.Descriptors.FileDescriptor |
||||
descriptor; |
||||
static { |
||||
java.lang.String[] descriptorData = { |
||||
"\n\014sample.proto\",\n\003Msg\022\013\n\003foo\030\001 \001(\t\022\030\n\004bl" + |
||||
"ah\030\002 \001(\0132\n.SecondMsg\"\031\n\tSecondMsg\022\014\n\004bla" + |
||||
"h\030\001 \001(\005B-\n\034org.springframework.protobufB" + |
||||
"\013OuterSampleP\001" |
||||
}; |
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = |
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { |
||||
public com.google.protobuf.ExtensionRegistry assignDescriptors( |
||||
com.google.protobuf.Descriptors.FileDescriptor root) { |
||||
descriptor = root; |
||||
internal_static_Msg_descriptor = |
||||
getDescriptor().getMessageTypes().get(0); |
||||
internal_static_Msg_fieldAccessorTable = new |
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable( |
||||
internal_static_Msg_descriptor, |
||||
new java.lang.String[] { "Foo", "Blah", }); |
||||
internal_static_SecondMsg_descriptor = |
||||
getDescriptor().getMessageTypes().get(1); |
||||
internal_static_SecondMsg_fieldAccessorTable = new |
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable( |
||||
internal_static_SecondMsg_descriptor, |
||||
new java.lang.String[] { "Blah", }); |
||||
return null; |
||||
} |
||||
}; |
||||
com.google.protobuf.Descriptors.FileDescriptor |
||||
.internalBuildGeneratedFileFrom(descriptorData, |
||||
new com.google.protobuf.Descriptors.FileDescriptor[] { |
||||
}, assigner); |
||||
} |
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
} |
@ -0,0 +1,389 @@
@@ -0,0 +1,389 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: sample.proto
|
||||
|
||||
package org.springframework.messaging.protobuf; |
||||
|
||||
/** |
||||
* Protobuf type {@code SecondMsg} |
||||
*/ |
||||
public final class SecondMsg extends |
||||
com.google.protobuf.GeneratedMessage |
||||
implements SecondMsgOrBuilder { |
||||
// Use SecondMsg.newBuilder() to construct.
|
||||
private SecondMsg(com.google.protobuf.GeneratedMessage.Builder<?> builder) { |
||||
super(builder); |
||||
this.unknownFields = builder.getUnknownFields(); |
||||
} |
||||
private SecondMsg(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } |
||||
|
||||
private static final SecondMsg defaultInstance; |
||||
public static SecondMsg getDefaultInstance() { |
||||
return defaultInstance; |
||||
} |
||||
|
||||
public SecondMsg getDefaultInstanceForType() { |
||||
return defaultInstance; |
||||
} |
||||
|
||||
private final com.google.protobuf.UnknownFieldSet unknownFields; |
||||
@java.lang.Override |
||||
public final com.google.protobuf.UnknownFieldSet |
||||
getUnknownFields() { |
||||
return this.unknownFields; |
||||
} |
||||
private SecondMsg( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
initFields(); |
||||
@SuppressWarnings("unused") |
||||
int mutable_bitField0_ = 0; |
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields = |
||||
com.google.protobuf.UnknownFieldSet.newBuilder(); |
||||
try { |
||||
boolean done = false; |
||||
while (!done) { |
||||
int tag = input.readTag(); |
||||
switch (tag) { |
||||
case 0: |
||||
done = true; |
||||
break; |
||||
default: { |
||||
if (!parseUnknownField(input, unknownFields, |
||||
extensionRegistry, tag)) { |
||||
done = true; |
||||
} |
||||
break; |
||||
} |
||||
case 8: { |
||||
bitField0_ |= 0x00000001; |
||||
blah_ = input.readInt32(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) { |
||||
throw e.setUnfinishedMessage(this); |
||||
} catch (java.io.IOException e) { |
||||
throw new com.google.protobuf.InvalidProtocolBufferException( |
||||
e.getMessage()).setUnfinishedMessage(this); |
||||
} finally { |
||||
this.unknownFields = unknownFields.build(); |
||||
makeExtensionsImmutable(); |
||||
} |
||||
} |
||||
public static final com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptor() { |
||||
return OuterSample.internal_static_SecondMsg_descriptor; |
||||
} |
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internalGetFieldAccessorTable() { |
||||
return OuterSample.internal_static_SecondMsg_fieldAccessorTable |
||||
.ensureFieldAccessorsInitialized( |
||||
SecondMsg.class, SecondMsg.Builder.class); |
||||
} |
||||
|
||||
public static com.google.protobuf.Parser<SecondMsg> PARSER = |
||||
new com.google.protobuf.AbstractParser<SecondMsg>() { |
||||
public SecondMsg parsePartialFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return new SecondMsg(input, extensionRegistry); |
||||
} |
||||
}; |
||||
|
||||
@java.lang.Override |
||||
public com.google.protobuf.Parser<SecondMsg> getParserForType() { |
||||
return PARSER; |
||||
} |
||||
|
||||
private int bitField0_; |
||||
// optional int32 blah = 1;
|
||||
public static final int BLAH_FIELD_NUMBER = 1; |
||||
private int blah_; |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public boolean hasBlah() { |
||||
return ((bitField0_ & 0x00000001) == 0x00000001); |
||||
} |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public int getBlah() { |
||||
return blah_; |
||||
} |
||||
|
||||
private void initFields() { |
||||
blah_ = 0; |
||||
} |
||||
private byte memoizedIsInitialized = -1; |
||||
public final boolean isInitialized() { |
||||
byte isInitialized = memoizedIsInitialized; |
||||
if (isInitialized != -1) return isInitialized == 1; |
||||
|
||||
memoizedIsInitialized = 1; |
||||
return true; |
||||
} |
||||
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output) |
||||
throws java.io.IOException { |
||||
getSerializedSize(); |
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) { |
||||
output.writeInt32(1, blah_); |
||||
} |
||||
getUnknownFields().writeTo(output); |
||||
} |
||||
|
||||
private int memoizedSerializedSize = -1; |
||||
public int getSerializedSize() { |
||||
int size = memoizedSerializedSize; |
||||
if (size != -1) return size; |
||||
|
||||
size = 0; |
||||
if (((bitField0_ & 0x00000001) == 0x00000001)) { |
||||
size += com.google.protobuf.CodedOutputStream |
||||
.computeInt32Size(1, blah_); |
||||
} |
||||
size += getUnknownFields().getSerializedSize(); |
||||
memoizedSerializedSize = size; |
||||
return size; |
||||
} |
||||
|
||||
private static final long serialVersionUID = 0L; |
||||
@java.lang.Override |
||||
protected java.lang.Object writeReplace() |
||||
throws java.io.ObjectStreamException { |
||||
return super.writeReplace(); |
||||
} |
||||
|
||||
public static SecondMsg parseFrom( |
||||
com.google.protobuf.ByteString data) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data); |
||||
} |
||||
public static SecondMsg parseFrom( |
||||
com.google.protobuf.ByteString data, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data, extensionRegistry); |
||||
} |
||||
public static SecondMsg parseFrom(byte[] data) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data); |
||||
} |
||||
public static SecondMsg parseFrom( |
||||
byte[] data, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws com.google.protobuf.InvalidProtocolBufferException { |
||||
return PARSER.parseFrom(data, extensionRegistry); |
||||
} |
||||
public static SecondMsg parseFrom(java.io.InputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input); |
||||
} |
||||
public static SecondMsg parseFrom( |
||||
java.io.InputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input, extensionRegistry); |
||||
} |
||||
public static SecondMsg parseDelimitedFrom(java.io.InputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseDelimitedFrom(input); |
||||
} |
||||
public static SecondMsg parseDelimitedFrom( |
||||
java.io.InputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseDelimitedFrom(input, extensionRegistry); |
||||
} |
||||
public static SecondMsg parseFrom( |
||||
com.google.protobuf.CodedInputStream input) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input); |
||||
} |
||||
public static SecondMsg parseFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
return PARSER.parseFrom(input, extensionRegistry); |
||||
} |
||||
|
||||
public static Builder newBuilder() { return Builder.create(); } |
||||
public Builder newBuilderForType() { return newBuilder(); } |
||||
public static Builder newBuilder(SecondMsg prototype) { |
||||
return newBuilder().mergeFrom(prototype); |
||||
} |
||||
public Builder toBuilder() { return newBuilder(this); } |
||||
|
||||
@java.lang.Override |
||||
protected Builder newBuilderForType( |
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) { |
||||
Builder builder = new Builder(parent); |
||||
return builder; |
||||
} |
||||
/** |
||||
* Protobuf type {@code SecondMsg} |
||||
*/ |
||||
public static final class Builder extends |
||||
com.google.protobuf.GeneratedMessage.Builder<Builder> |
||||
implements SecondMsgOrBuilder { |
||||
public static final com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptor() { |
||||
return OuterSample.internal_static_SecondMsg_descriptor; |
||||
} |
||||
|
||||
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable |
||||
internalGetFieldAccessorTable() { |
||||
return OuterSample.internal_static_SecondMsg_fieldAccessorTable |
||||
.ensureFieldAccessorsInitialized( |
||||
SecondMsg.class, SecondMsg.Builder.class); |
||||
} |
||||
|
||||
// Construct using org.springframework.messaging.protobuf.SecondMsg.newBuilder()
|
||||
private Builder() { |
||||
maybeForceBuilderInitialization(); |
||||
} |
||||
|
||||
private Builder( |
||||
com.google.protobuf.GeneratedMessage.BuilderParent parent) { |
||||
super(parent); |
||||
maybeForceBuilderInitialization(); |
||||
} |
||||
private void maybeForceBuilderInitialization() { |
||||
if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { |
||||
} |
||||
} |
||||
private static Builder create() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
public Builder clear() { |
||||
super.clear(); |
||||
blah_ = 0; |
||||
bitField0_ = (bitField0_ & ~0x00000001); |
||||
return this; |
||||
} |
||||
|
||||
public Builder clone() { |
||||
return create().mergeFrom(buildPartial()); |
||||
} |
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor |
||||
getDescriptorForType() { |
||||
return OuterSample.internal_static_SecondMsg_descriptor; |
||||
} |
||||
|
||||
public SecondMsg getDefaultInstanceForType() { |
||||
return SecondMsg.getDefaultInstance(); |
||||
} |
||||
|
||||
public SecondMsg build() { |
||||
SecondMsg result = buildPartial(); |
||||
if (!result.isInitialized()) { |
||||
throw newUninitializedMessageException(result); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public SecondMsg buildPartial() { |
||||
SecondMsg result = new SecondMsg(this); |
||||
int from_bitField0_ = bitField0_; |
||||
int to_bitField0_ = 0; |
||||
if (((from_bitField0_ & 0x00000001) == 0x00000001)) { |
||||
to_bitField0_ |= 0x00000001; |
||||
} |
||||
result.blah_ = blah_; |
||||
result.bitField0_ = to_bitField0_; |
||||
onBuilt(); |
||||
return result; |
||||
} |
||||
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) { |
||||
if (other instanceof SecondMsg) { |
||||
return mergeFrom((SecondMsg)other); |
||||
} else { |
||||
super.mergeFrom(other); |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public Builder mergeFrom(SecondMsg other) { |
||||
if (other == SecondMsg.getDefaultInstance()) return this; |
||||
if (other.hasBlah()) { |
||||
setBlah(other.getBlah()); |
||||
} |
||||
this.mergeUnknownFields(other.getUnknownFields()); |
||||
return this; |
||||
} |
||||
|
||||
public final boolean isInitialized() { |
||||
return true; |
||||
} |
||||
|
||||
public Builder mergeFrom( |
||||
com.google.protobuf.CodedInputStream input, |
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry) |
||||
throws java.io.IOException { |
||||
SecondMsg parsedMessage = null; |
||||
try { |
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); |
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) { |
||||
parsedMessage = (SecondMsg) e.getUnfinishedMessage(); |
||||
throw e; |
||||
} finally { |
||||
if (parsedMessage != null) { |
||||
mergeFrom(parsedMessage); |
||||
} |
||||
} |
||||
return this; |
||||
} |
||||
private int bitField0_; |
||||
|
||||
// optional int32 blah = 1;
|
||||
private int blah_ ; |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public boolean hasBlah() { |
||||
return ((bitField0_ & 0x00000001) == 0x00000001); |
||||
} |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public int getBlah() { |
||||
return blah_; |
||||
} |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public Builder setBlah(int value) { |
||||
bitField0_ |= 0x00000001; |
||||
blah_ = value; |
||||
onChanged(); |
||||
return this; |
||||
} |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
public Builder clearBlah() { |
||||
bitField0_ = (bitField0_ & ~0x00000001); |
||||
blah_ = 0; |
||||
onChanged(); |
||||
return this; |
||||
} |
||||
|
||||
// @@protoc_insertion_point(builder_scope:SecondMsg)
|
||||
} |
||||
|
||||
static { |
||||
defaultInstance = new SecondMsg(true); |
||||
defaultInstance.initFields(); |
||||
} |
||||
|
||||
// @@protoc_insertion_point(class_scope:SecondMsg)
|
||||
} |
||||
|
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: sample.proto
|
||||
|
||||
package org.springframework.messaging.protobuf; |
||||
|
||||
public interface SecondMsgOrBuilder |
||||
extends com.google.protobuf.MessageOrBuilder { |
||||
|
||||
// optional int32 blah = 1;
|
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
boolean hasBlah(); |
||||
/** |
||||
* <code>optional int32 blah = 1;</code> |
||||
*/ |
||||
int getBlah(); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
option java_package = "org.springframework.protobuf.messaging"; |
||||
option java_outer_classname = "OuterSample"; |
||||
option java_multiple_files = true; |
||||
|
||||
message Msg { |
||||
optional string foo = 1; |
||||
optional SecondMsg blah = 2; |
||||
} |
||||
|
||||
message SecondMsg { |
||||
optional int32 blah = 1; |
||||
} |
Loading…
Reference in new issue