summaryrefslogtreecommitdiff
path: root/groot-formats
diff options
context:
space:
mode:
authorlifengchao <[email protected]>2024-01-09 18:31:56 +0800
committerlifengchao <[email protected]>2024-01-09 18:31:56 +0800
commit79c961f6e358f479ae5295a16f5e95b29ea7d7c0 (patch)
tree3e08148d8008303d255f90334043c5633cafe6c5 /groot-formats
parentd306291e6438823bf0d6502ffef3f20b49c1a293 (diff)
[feature][format-protobuf] 添加测试类和shaded实现。
Diffstat (limited to 'groot-formats')
-rw-r--r--groot-formats/format-protobuf/pom.xml74
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventDeserializationSchema.java136
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventSerializationSchema.java78
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufFormatFactory.java174
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufSerializer.java1678
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufUtils.java170
-rw-r--r--groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/SchemaConverters.java1614
-rw-r--r--groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/Proto3TypesProtos.java7606
-rw-r--r--groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufEventSchemaTest.java1290
-rw-r--r--groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufFileConverterTest.java72
10 files changed, 6535 insertions, 6357 deletions
diff --git a/groot-formats/format-protobuf/pom.xml b/groot-formats/format-protobuf/pom.xml
index e2488a1..7f77507 100644
--- a/groot-formats/format-protobuf/pom.xml
+++ b/groot-formats/format-protobuf/pom.xml
@@ -1,32 +1,44 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>com.geedgenetworks</groupId>
- <artifactId>groot-formats</artifactId>
- <version>${revision}</version>
- </parent>
-
- <artifactId>format-protobuf</artifactId>
- <name>Groot : Formats : Format-Protobuf </name>
-
- <properties>
- <protobuf.version>3.23.4</protobuf.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>${protobuf.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java-util</artifactId>
- <version>${protobuf.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.geedgenetworks</groupId>
+ <artifactId>groot-formats</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>format-protobuf</artifactId>
+ <name>Groot : Formats : Format-Protobuf </name>
+
+ <properties>
+ <protobuf.version>3.23.4</protobuf.version>
+ </properties>
+
+ <dependencies>
+ <!--<dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>${protobuf.version}</version>
+ </dependency>-->
+ <!--<dependency>
+ <groupId>com.geedgenetworks</groupId>
+ <artifactId>protobuf-shaded</artifactId>
+ <version>${protobuf.version}</version>
+ </dependency>-->
+ <dependency>
+ <groupId>com.geedgenetworks</groupId>
+ <artifactId>protobuf-shade</artifactId>
+ <version>${protobuf.version}</version>
+ <scope>system</scope>
+ <systemPath>${project.basedir}/../../lib/protobuf-shaded-3.23.4.jar</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.flink</groupId>
+ <artifactId>flink-connector-kafka_${scala.version}</artifactId>
+ <version>${flink.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventDeserializationSchema.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventDeserializationSchema.java
index 194904b..50b2274 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventDeserializationSchema.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventDeserializationSchema.java
@@ -1,68 +1,68 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.geedgenetworks.core.pojo.Event;
-import com.geedgenetworks.core.types.StructType;
-import com.google.protobuf.Descriptors.Descriptor;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Base64;
-import java.util.Map;
-
-public class ProtobufEventDeserializationSchema implements DeserializationSchema<Event> {
- private static final Logger LOG = LoggerFactory.getLogger(ProtobufEventDeserializationSchema.class);
- private final String messageName;
- private final byte[] binaryFileDescriptorSet;
- private final StructType dataType;
- private final boolean ignoreParseErrors;
- private final boolean emitDefaultValues;
- transient private SchemaConverters.MessageConverter converter;
-
- public ProtobufEventDeserializationSchema(String messageName, byte[] binaryFileDescriptorSet, StructType dataType, boolean ignoreParseErrors, boolean emitDefaultValues) {
- this.messageName = messageName;
- this.binaryFileDescriptorSet = binaryFileDescriptorSet;
- this.dataType = dataType;
- this.ignoreParseErrors = ignoreParseErrors;
- this.emitDefaultValues = emitDefaultValues;
- }
-
- @Override
- public void open(InitializationContext context) throws Exception {
- Descriptor descriptor = ProtobufUtils.buildDescriptor(binaryFileDescriptorSet, messageName);
- this.converter = new SchemaConverters.MessageConverter(descriptor, dataType, emitDefaultValues);
- }
-
- @Override
- public Event deserialize(byte[] message) throws IOException {
- if(message == null){
- return null;
- }
-
- try {
- Map<String, Object> map = converter.converter(message);
- Event event = new Event();
- event.setExtractedFields(map);
- return event;
- } catch (Exception e) {
- LOG.error(String.format("proto解析失败for:%s", Base64.getEncoder().encodeToString(message)), e);
- if(ignoreParseErrors){
- return null;
- }else{
- throw new IOException(e);
- }
- }
- }
-
- @Override
- public boolean isEndOfStream(Event nextElement) {
- return false;
- }
-
- @Override
- public TypeInformation<Event> getProducedType() {
- return null;
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.geedgenetworks.core.pojo.Event;
+import com.geedgenetworks.core.types.StructType;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Map;
+
+public class ProtobufEventDeserializationSchema implements DeserializationSchema<Event> {
+ private static final Logger LOG = LoggerFactory.getLogger(ProtobufEventDeserializationSchema.class);
+ private final String messageName;
+ private final byte[] binaryFileDescriptorSet;
+ private final StructType dataType;
+ private final boolean ignoreParseErrors;
+ private final boolean emitDefaultValues;
+ transient private SchemaConverters.MessageConverter converter;
+
+ public ProtobufEventDeserializationSchema(String messageName, byte[] binaryFileDescriptorSet, StructType dataType, boolean ignoreParseErrors, boolean emitDefaultValues) {
+ this.messageName = messageName;
+ this.binaryFileDescriptorSet = binaryFileDescriptorSet;
+ this.dataType = dataType;
+ this.ignoreParseErrors = ignoreParseErrors;
+ this.emitDefaultValues = emitDefaultValues;
+ }
+
+ @Override
+ public void open(InitializationContext context) throws Exception {
+ Descriptor descriptor = ProtobufUtils.buildDescriptor(binaryFileDescriptorSet, messageName);
+ this.converter = new SchemaConverters.MessageConverter(descriptor, dataType, emitDefaultValues);
+ }
+
+ @Override
+ public Event deserialize(byte[] message) throws IOException {
+ if(message == null){
+ return null;
+ }
+
+ try {
+ Map<String, Object> map = converter.converter(message);
+ Event event = new Event();
+ event.setExtractedFields(map);
+ return event;
+ } catch (Exception e) {
+ LOG.error(String.format("proto解析失败for:%s", Base64.getEncoder().encodeToString(message)), e);
+ if(ignoreParseErrors){
+ return null;
+ }else{
+ throw new IOException(e);
+ }
+ }
+ }
+
+ @Override
+ public boolean isEndOfStream(Event nextElement) {
+ return false;
+ }
+
+ @Override
+ public TypeInformation<Event> getProducedType() {
+ return null;
+ }
+}
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventSerializationSchema.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventSerializationSchema.java
index 204a012..ebf9f2e 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventSerializationSchema.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufEventSerializationSchema.java
@@ -1,39 +1,39 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.alibaba.fastjson2.JSON;
-import com.geedgenetworks.core.pojo.Event;
-import com.google.protobuf.Descriptors;
-import org.apache.flink.api.common.serialization.SerializationSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-
-public class ProtobufEventSerializationSchema implements SerializationSchema<Event> {
- private static final Logger LOG = LoggerFactory.getLogger(ProtobufEventSerializationSchema.class);
- private final String messageName;
- private final byte[] binaryFileDescriptorSet;
- transient private ProtobufSerializer serializer;
-
- public ProtobufEventSerializationSchema(String messageName, byte[] binaryFileDescriptorSet) {
- this.messageName = messageName;
- this.binaryFileDescriptorSet = binaryFileDescriptorSet;
- }
-
- @Override
- public void open(InitializationContext context) throws Exception {
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(binaryFileDescriptorSet, messageName);
- serializer = new ProtobufSerializer(descriptor);
- }
-
- @Override
- public byte[] serialize(Event element) {
- Map<String, Object> map = element.getExtractedFields();
- try {
- return serializer.serialize(map);
- } catch (Exception e) {
- LOG.error(String.format("proto serialize失败for:%s", JSON.toJSONString(map)), e);
- return null;
- }
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.alibaba.fastjson2.JSON;
+import com.geedgenetworks.core.pojo.Event;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors;
+import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class ProtobufEventSerializationSchema implements SerializationSchema<Event> {
+ private static final Logger LOG = LoggerFactory.getLogger(ProtobufEventSerializationSchema.class);
+ private final String messageName;
+ private final byte[] binaryFileDescriptorSet;
+ transient private ProtobufSerializer serializer;
+
+ public ProtobufEventSerializationSchema(String messageName, byte[] binaryFileDescriptorSet) {
+ this.messageName = messageName;
+ this.binaryFileDescriptorSet = binaryFileDescriptorSet;
+ }
+
+ @Override
+ public void open(InitializationContext context) throws Exception {
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(binaryFileDescriptorSet, messageName);
+ serializer = new ProtobufSerializer(descriptor);
+ }
+
+ @Override
+ public byte[] serialize(Event element) {
+ Map<String, Object> map = element.getExtractedFields();
+ try {
+ return serializer.serialize(map);
+ } catch (Exception e) {
+ LOG.error(String.format("proto serialize失败for:%s", JSON.toJSONString(map)), e);
+ return null;
+ }
+ }
+}
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufFormatFactory.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufFormatFactory.java
index f553c4c..6e2e350 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufFormatFactory.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufFormatFactory.java
@@ -1,87 +1,87 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.geedgenetworks.core.connector.format.DecodingFormat;
-import com.geedgenetworks.core.connector.format.EncodingFormat;
-import com.geedgenetworks.core.factories.DecodingFormatFactory;
-import com.geedgenetworks.core.factories.EncodingFormatFactory;
-import com.geedgenetworks.core.factories.TableFactory;
-import com.geedgenetworks.core.pojo.Event;
-import com.geedgenetworks.core.types.StructType;
-import com.google.protobuf.Descriptors;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
-import org.apache.flink.api.common.serialization.SerializationSchema;
-import org.apache.flink.configuration.ConfigOption;
-import org.apache.flink.configuration.ReadableConfig;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static com.geedgenetworks.formats.protobuf.ProtobufOptions.*;
-
-public class ProtobufFormatFactory implements DecodingFormatFactory, EncodingFormatFactory {
- public static final String IDENTIFIER = "protobuf";
-
- @Override
- public String factoryIdentifier() {
- return IDENTIFIER;
- }
-
- @Override
- public DecodingFormat createDecodingFormat(TableFactory.Context context, ReadableConfig formatOptions) {
- final String messageName = formatOptions.get(MESSAGE_NAME);
- final String descFilePath = formatOptions.get(DESC_FILE_PATH);
- final boolean ignoreParseErrors = formatOptions.get(IGNORE_PARSE_ERRORS);
- final boolean emitDefaultValues = formatOptions.get(EMIT_DEFAULT_VALUES);
- final byte[] fileContent = ProtobufUtils.readDescriptorFileContent(descFilePath);
- return new DecodingFormat() {
- @Override
- public DeserializationSchema<Event> createRuntimeDecoder(StructType dataType) {
- try {
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(fileContent, messageName);
- if(dataType == null) {
- dataType = SchemaConverters.toStructType(descriptor);
- }
- ProtobufUtils.checkSupportParseDescriptor(descriptor);
- SchemaConverters.checkMatch(descriptor, dataType);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return new ProtobufEventDeserializationSchema(messageName, fileContent, dataType, ignoreParseErrors, emitDefaultValues);
- }
- };
- }
-
- @Override
- public EncodingFormat createEncodingFormat(TableFactory.Context context, ReadableConfig formatOptions) {
- final String messageName = formatOptions.get(MESSAGE_NAME);
- final String descFilePath = formatOptions.get(DESC_FILE_PATH);
- final byte[] fileContent = ProtobufUtils.readDescriptorFileContent(descFilePath);
- try {
- ProtobufUtils.checkSupportParseDescriptor(ProtobufUtils.buildDescriptor(fileContent, messageName));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return new EncodingFormat() {
- @Override
- public SerializationSchema<Event> createRuntimeEncoder(StructType dataType) {
- return new ProtobufEventSerializationSchema(messageName, fileContent);
- }
- };
- }
-
- @Override
- public Set<ConfigOption<?>> requiredOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.add(MESSAGE_NAME);
- options.add(DESC_FILE_PATH);
- return options;
- }
-
- @Override
- public Set<ConfigOption<?>> optionalOptions() {
- Set<ConfigOption<?>> options = new HashSet<>();
- options.add(IGNORE_PARSE_ERRORS);
- options.add(EMIT_DEFAULT_VALUES);
- return options;
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.geedgenetworks.core.connector.format.DecodingFormat;
+import com.geedgenetworks.core.connector.format.EncodingFormat;
+import com.geedgenetworks.core.factories.DecodingFormatFactory;
+import com.geedgenetworks.core.factories.EncodingFormatFactory;
+import com.geedgenetworks.core.factories.TableFactory;
+import com.geedgenetworks.core.pojo.Event;
+import com.geedgenetworks.core.types.StructType;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors;
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.ReadableConfig;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static com.geedgenetworks.formats.protobuf.ProtobufOptions.*;
+
+public class ProtobufFormatFactory implements DecodingFormatFactory, EncodingFormatFactory {
+ public static final String IDENTIFIER = "protobuf";
+
+ @Override
+ public String factoryIdentifier() {
+ return IDENTIFIER;
+ }
+
+ @Override
+ public DecodingFormat createDecodingFormat(TableFactory.Context context, ReadableConfig formatOptions) {
+ final String messageName = formatOptions.get(MESSAGE_NAME);
+ final String descFilePath = formatOptions.get(DESC_FILE_PATH);
+ final boolean ignoreParseErrors = formatOptions.get(IGNORE_PARSE_ERRORS);
+ final boolean emitDefaultValues = formatOptions.get(EMIT_DEFAULT_VALUES);
+ final byte[] fileContent = ProtobufUtils.readDescriptorFileContent(descFilePath);
+ return new DecodingFormat() {
+ @Override
+ public DeserializationSchema<Event> createRuntimeDecoder(StructType dataType) {
+ try {
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(fileContent, messageName);
+ if(dataType == null) {
+ dataType = SchemaConverters.toStructType(descriptor);
+ }
+ ProtobufUtils.checkSupportParseDescriptor(descriptor);
+ SchemaConverters.checkMatch(descriptor, dataType);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return new ProtobufEventDeserializationSchema(messageName, fileContent, dataType, ignoreParseErrors, emitDefaultValues);
+ }
+ };
+ }
+
+ @Override
+ public EncodingFormat createEncodingFormat(TableFactory.Context context, ReadableConfig formatOptions) {
+ final String messageName = formatOptions.get(MESSAGE_NAME);
+ final String descFilePath = formatOptions.get(DESC_FILE_PATH);
+ final byte[] fileContent = ProtobufUtils.readDescriptorFileContent(descFilePath);
+ try {
+ ProtobufUtils.checkSupportParseDescriptor(ProtobufUtils.buildDescriptor(fileContent, messageName));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return new EncodingFormat() {
+ @Override
+ public SerializationSchema<Event> createRuntimeEncoder(StructType dataType) {
+ return new ProtobufEventSerializationSchema(messageName, fileContent);
+ }
+ };
+ }
+
+ @Override
+ public Set<ConfigOption<?>> requiredOptions() {
+ Set<ConfigOption<?>> options = new HashSet<>();
+ options.add(MESSAGE_NAME);
+ options.add(DESC_FILE_PATH);
+ return options;
+ }
+
+ @Override
+ public Set<ConfigOption<?>> optionalOptions() {
+ Set<ConfigOption<?>> options = new HashSet<>();
+ options.add(IGNORE_PARSE_ERRORS);
+ options.add(EMIT_DEFAULT_VALUES);
+ return options;
+ }
+}
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufSerializer.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufSerializer.java
index 0891f32..787cc25 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufSerializer.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufSerializer.java
@@ -1,839 +1,839 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.google.protobuf.CodedOutputStream;
-import com.google.protobuf.Descriptors.Descriptor;
-import com.google.protobuf.Descriptors.EnumValueDescriptor;
-import com.google.protobuf.Descriptors.FieldDescriptor;
-import com.google.protobuf.WireFormat;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Supplier;
-
-public class ProtobufSerializer {
- final MessageData messageData;
-
- public ProtobufSerializer(Descriptor descriptor) {
- ProtobufUtils.checkSupportParseDescriptor(descriptor);
- messageData = new MessageData(descriptor);
- }
-
- public byte[] serialize(Map<String, Object> data) throws Exception {
- messageData.feed(data);
- byte[] result = new byte[messageData.getSerializedSize()];
- CodedOutputStream output = CodedOutputStream.newInstance(result);
- messageData.writeTo(output);
- output.checkNoSpaceLeft();
- return result;
- }
-
- static double convertToDouble(Object obj) throws Exception {
- if (obj instanceof Double) {
- return (Double) obj;
- } else if (obj instanceof Number) {
- return ((Number) obj).doubleValue();
- } else if (obj instanceof String) {
- return Double.parseDouble((String) obj);
- } else {
- throw new IllegalArgumentException("can not convert to double");
- }
- }
-
- static float convertToFloat(Object obj) throws Exception {
- if (obj instanceof Float) {
- return (Float) obj;
- } else if (obj instanceof Number) {
- return ((Number) obj).floatValue();
- } else if (obj instanceof String) {
- return Float.parseFloat((String) obj);
- } else {
- throw new IllegalArgumentException("can not convert to double");
- }
- }
-
- static int convertToInt(Object obj) throws Exception {
- if (obj instanceof Integer) {
- return (Integer) obj;
- } else if (obj instanceof Number) {
- return ((Number) obj).intValue();
- } else if (obj instanceof String) {
- return Integer.parseInt((String) obj);
- } else {
- throw new IllegalArgumentException("can not convert to double");
- }
- }
-
- static long convertToLong(Object obj) throws Exception {
- if (obj instanceof Long) {
- return (Long) obj;
- } else if (obj instanceof Number) {
- return ((Number) obj).longValue();
- } else if (obj instanceof String) {
- return Long.parseLong((String) obj);
- } else {
- throw new IllegalArgumentException("can not convert to long:" + obj);
- }
- }
-
- static boolean convertToBool(Object obj) throws Exception {
- if (obj instanceof Boolean) {
- return (Boolean) obj;
- } else if (obj instanceof Number) {
- return ((Number) obj).intValue() != 0;
- } else {
- throw new IllegalArgumentException("can not convert to double");
- }
- }
-
- static class MessageData extends ProtobufData {
- final FieldData[] fieldDatas;
- final Map<String, FieldData> fieldDataMap;
- int memoizedSize = -1;
-
- public MessageData(Descriptor descriptor) {
- List<FieldDescriptor> fields = descriptor.getFields();
- fieldDatas = new FieldData[fields.size()];
- fieldDataMap = new HashMap<>();
- for (int i = 0; i < fields.size(); i++) {
- fieldDatas[i] = FieldData.newInstance(fields.get(i));
- fieldDataMap.put(fieldDatas[i].name, fieldDatas[i]);
- }
- }
-
- @Override
- public int getSerializedSize() {
- if(memoizedSize != -1){
- return memoizedSize;
- }
-
- int size = 0;
- FieldData fieldData;
- for (int i = 0; i < fieldDatas.length; i++) {
- fieldData = fieldDatas[i];
- if (fieldData.isNotNull()) {
- size += fieldData.getSerializedSize();
- //System.out.println(fieldData.name + " -> " + size);
- }
- }
-
- memoizedSize = size;
- return size;
- }
-
- @Override
- public boolean feed(Object obj) throws Exception {
- memoizedSize = -1;
- Map<String, Object> map = (Map<String, Object>) obj;
- FieldData fieldData;
- for (int i = 0; i < fieldDatas.length; i++) {
- fieldData = fieldDatas[i];
- fieldData.reset();
- }
- for (Map.Entry<String, Object> entry : map.entrySet()) {
- fieldData = fieldDataMap.get(entry.getKey());
- if(fieldData != null) {
- Object value = entry.getValue();
- if (value != null) {
- fieldData.feed(value);
- }
- }
- }
- return true;
- }
-
- /*@Override
- public boolean feed(Object obj) throws Exception {
- memoizedSize = -1;
- Map<String, Object> map = (Map<String, Object>) obj;
- FieldData fieldData;
- for (int i = 0; i < fieldDatas.length; i++) {
- fieldData = fieldDatas[i];
- fieldData.reset();
- Object value = map.get(fieldData.name);
- if (value != null) {
- fieldData.feed(value);
- }
- }
- return true;
- }*/
-
- @Override
- public void writeTo(CodedOutputStream output) throws Exception {
- FieldData fieldData;
- for (int i = 0; i < fieldDatas.length; i++) {
- fieldData = fieldDatas[i];
- if (fieldData.isNotNull()) {
- fieldData.writeTo(output);
- //System.out.println(fieldData.name + " -> " + output.spaceLeft());
- }
- }
- }
- }
-
- static abstract class FieldData {
- final int tag;
- final int tagSize;
- final FieldDescriptor field;
-
- final String name;
- final boolean message;
- final boolean optional;
- final boolean packed;
- final boolean repeated;
-
- FieldData(int tag, int tagSize, FieldDescriptor field) {
- this.tag = tag;
- this.tagSize = tagSize;
- this.field = field;
- this.name = field.getName();
- this.message = field.getType() == FieldDescriptor.Type.MESSAGE;
- this.optional = field.hasOptionalKeyword();
- this.packed = field.isPacked();
- this.repeated = field.isRepeated();
- }
-
- abstract void reset();
-
- abstract boolean isNotNull();
-
- abstract int getSerializedSize();
-
- abstract void feed(Object obj) throws Exception;
-
- abstract void writeTo(CodedOutputStream output) throws Exception;
-
- static FieldData newInstance(FieldDescriptor field) {
- WireFormat.FieldType type = field.getLiteType();
- int tag = makeTag(field.getNumber(), getWireFormatForFieldType(type, field.isPacked()));
- int tagSize = CodedOutputStream.computeTagSize(field.getNumber());
- Supplier<ProtobufData> dataSupplier = getProtobufDataSupplier(field);
- if (field.isRepeated()) {
- return new ArrayFieldData(tag, tagSize, field, dataSupplier);
- } else {
- return new ValueFieldData(tag, tagSize, field, dataSupplier.get());
- }
- }
-
- static Supplier<ProtobufData> getProtobufDataSupplier(FieldDescriptor field) {
- switch (field.getLiteType()) {
- case DOUBLE:
- return () -> new DoubleData();
- case FLOAT:
- return () -> new FloatData();
- case INT64:
- return () -> new Int64Data();
- case UINT64:
- return () -> new Uint64Data();
- case FIXED64:
- return () -> new Fixed64Data();
- case SFIXED64:
- return () -> new SFixed64Data();
- case SINT64:
- return () -> new SInt64Data();
- case INT32:
- return () -> new Int32Data();
- case UINT32:
- return () -> new Uint32Data();
- case FIXED32:
- return () -> new Fixed32Data();
- case SFIXED32:
- return () -> new SFixed32Data();
- case SINT32:
- return () -> new SInt32Data();
- case STRING:
- return () -> new StringData();
- case BYTES:
- return () -> new BytesData();
- case BOOL:
- return () -> new BoolData();
- case MESSAGE:
- return () -> new MessageData(field.getMessageType());
- case ENUM:
- int number = ((EnumValueDescriptor) field.getDefaultValue()).getNumber();
- return () -> new EnumData(number);
- default:
- throw new IllegalArgumentException(String.format("not supported type:%s(%s)", field.getType(), field.getName()));
- }
- }
- }
-
- static class ValueFieldData extends FieldData {
- final ProtobufData data;
- boolean notNull = false;
-
- ValueFieldData(int tag, int tagSize, FieldDescriptor field, ProtobufData data) {
- super(tag, tagSize, field);
- this.data = data;
- }
-
- @Override
- void reset() {
- notNull = false;
- }
-
- @Override
- boolean isNotNull() {
- return notNull;
- }
-
- @Override
- int getSerializedSize() {
- if (message) {
- return tagSize + computeLengthDelimitedFieldSize(data.getSerializedSize());
- } else {
- return tagSize + data.getSerializedSize();
- }
- }
-
- @Override
- void feed(Object obj) throws Exception {
- notNull = data.feed(obj);
- if(optional){
- notNull = true;
- }
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- // com.google.protobuf.FieldSet.writeElement
- output.writeUInt32NoTag(tag);
- if (message) {
- output.writeUInt32NoTag(data.getSerializedSize());
- }
- data.writeTo(output);
- }
- }
-
- static class ArrayFieldData extends FieldData {
- final List<ProtobufData> datas;
- private int pos = 0;
- int dataSize = 0;
- final Supplier<ProtobufData> dataSupplier;
-
- ArrayFieldData(int tag, int tagSize, FieldDescriptor field, Supplier<ProtobufData> dataSupplier) {
- super(tag, tagSize, field);
- this.datas = new ArrayList<>();
- this.dataSupplier = dataSupplier;
- }
-
- @Override
- void reset() {
- pos = 0;
- }
-
- @Override
- boolean isNotNull() {
- return pos != 0;
- }
-
- @Override
- int getSerializedSize() {
- // com.google.protobuf.FieldSet.computeFieldSize
- if (packed) {
- int size = 0;
- for (int i = 0; i < pos; i++) {
- size += message ? computeLengthDelimitedFieldSize(datas.get(i).getSerializedSize()) : datas.get(i).getSerializedSize();
- }
- dataSize = size;
- size += CodedOutputStream.computeUInt32SizeNoTag(size);
- return tagSize + size;
- } else {
- int size = 0;
- for (int i = 0; i < pos; i++) {
- size += tagSize;
- size += message ? computeLengthDelimitedFieldSize(datas.get(i).getSerializedSize()) : datas.get(i).getSerializedSize();
- }
- return size;
- }
- }
-
- @Override
- void feed(Object obj) throws Exception {
- List<Object> list = (List<Object>) obj;
- ProtobufData data;
- if(datas.size() < list.size()){
- int len = list.size() - datas.size();
- for (int i = 0; i < len; i++) {
- datas.add(dataSupplier.get());
- }
- }
- for (int i = 0; i < list.size(); i++) {
- data = datas.get(i);
- data.feed(list.get(i));
- }
- pos = list.size();
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- //com.google.protobuf.FieldSet.writeField
- if (packed) {
- output.writeUInt32NoTag(tag);
- output.writeUInt32NoTag(dataSize);
- for (int i = 0; i < pos; i++) {
- datas.get(i).writeTo(output);
- }
- } else {
- for (int i = 0; i < pos; i++) {
- output.writeUInt32NoTag(tag);
- if(message){
- output.writeUInt32NoTag(datas.get(i).getSerializedSize());
- }
- datas.get(i).writeTo(output);
- }
- }
- }
- }
-
- static class DoubleData extends ProtobufData {
- private double value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeDoubleSizeNoTag(value); // FIXED64_SIZE
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToDouble(obj);
- return value != 0D;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeDoubleNoTag(value);
- }
- }
-
- static class FloatData extends ProtobufData {
- private float value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeFloatSizeNoTag(value); // FIXED32_SIZE
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToFloat(obj);
- return value != 0F;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeFloatNoTag(value);
- }
- }
-
-
- static class Int32Data extends ProtobufData {
- private int value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeInt32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeInt32NoTag(value);
- }
- }
-
- static class Uint32Data extends ProtobufData {
- private int value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeInt32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeUInt32NoTag(value);
- }
- }
-
- static class Fixed32Data extends ProtobufData {
- private int value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeFixed32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeFixed32NoTag(value);
- }
- }
-
- static class SFixed32Data extends ProtobufData {
- private int value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeSFixed32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeSFixed32NoTag(value);
- }
- }
-
- static class SInt32Data extends ProtobufData {
- private int value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeSInt32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeSInt32NoTag(value);
- }
- }
-
- static class Int64Data extends ProtobufData {
- private long value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeInt64SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToLong(obj);
- return value != 0L;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeInt64NoTag(value);
- }
- }
-
- static class Uint64Data extends ProtobufData {
- private long value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeInt64SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToLong(obj);
- return value != 0L;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeUInt64NoTag(value);
- }
- }
-
- static class Fixed64Data extends ProtobufData {
- private long value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeFixed64SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToLong(obj);
- return value != 0L;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeFixed64NoTag(value);
- }
- }
-
- static class SFixed64Data extends ProtobufData {
- private long value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeSFixed64SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToLong(obj);
- return value != 0L;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeSFixed64NoTag(value);
- }
- }
-
- static class SInt64Data extends ProtobufData {
- private long value;
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeSInt64SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToLong(obj);
- return value != 0L;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeSInt64NoTag(value);
- }
- }
-
- static final int MAX_STR_BYTES_LENGTH = 1024 * 12;
- static class StringData extends ProtobufData {
- private final byte[] bytes = new byte[MAX_STR_BYTES_LENGTH];
- private byte[] value;
- private int len;
-
- @Override
- int getSerializedSize() {
- return computeLengthDelimitedFieldSize(len);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- String str = obj.toString();
- if(str.isEmpty()){
- value = bytes;
- len = 0;
- return false;
- }
- //value = str.getBytes(StandardCharsets.UTF_8);
- int length = str.length() * 3;
- if (length > MAX_STR_BYTES_LENGTH) {
- value = new byte[length];
- }else{
- value = bytes;
- }
-
- len = encodeUTF8(str, value);
- return true;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeUInt32NoTag(len);
- output.write(value, 0, len);
- }
- }
-
- static class BytesData extends ProtobufData {
- private byte[] value;
-
- @Override
- int getSerializedSize() {
- return computeLengthDelimitedFieldSize(value.length);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = (byte[]) obj;
- return value.length != 0;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeByteArrayNoTag(value);
- }
- }
-
- static class BoolData extends ProtobufData {
- private boolean value;
-
- @Override
- int getSerializedSize() {
- return 1;
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToBool(obj);
- return value;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeBoolNoTag(value);
- }
- }
-
- static class EnumData extends ProtobufData {
- private int value;
- final private int defaultValue;
-
- public EnumData(int defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- @Override
- int getSerializedSize() {
- return CodedOutputStream.computeInt32SizeNoTag(value);
- }
-
- @Override
- boolean feed(Object obj) throws Exception {
- value = convertToInt(obj);
- return value != defaultValue;
- }
-
- @Override
- void writeTo(CodedOutputStream output) throws Exception {
- output.writeInt32NoTag(value);
- }
- }
-
- static abstract class ProtobufData {
- abstract int getSerializedSize();
-
- abstract boolean feed(Object obj) throws Exception;
-
- abstract void writeTo(CodedOutputStream output) throws Exception;
- }
-
- // copy from org.apache.flink.table.runtime.util.StringUtf8Utils
- static int encodeUTF8(String str, byte[] bytes) {
- int offset = 0;
- int len = str.length();
- int sl = offset + len;
- int dp = 0;
- int dlASCII = dp + Math.min(len, bytes.length);
-
- // ASCII only optimized loop
- while (dp < dlASCII && str.charAt(offset) < '\u0080') {
- bytes[dp++] = (byte) str.charAt(offset++);
- }
-
- while (offset < sl) {
- char c = str.charAt(offset++);
- if (c < 0x80) {
- // Have at most seven bits
- bytes[dp++] = (byte) c;
- } else if (c < 0x800) {
- // 2 bytes, 11 bits
- bytes[dp++] = (byte) (0xc0 | (c >> 6));
- bytes[dp++] = (byte) (0x80 | (c & 0x3f));
- } else if (Character.isSurrogate(c)) {
- final int uc;
- int ip = offset - 1;
- if (Character.isHighSurrogate(c)) {
- if (sl - ip < 2) {
- uc = -1;
- } else {
- char d = str.charAt(ip + 1);
- if (Character.isLowSurrogate(d)) {
- uc = Character.toCodePoint(c, d);
- } else {
- // for some illegal character
- // the jdk will ignore the origin character and cast it to '?'
- // this acts the same with jdk
- return defaultEncodeUTF8(str, bytes);
- }
- }
- } else {
- if (Character.isLowSurrogate(c)) {
- // for some illegal character
- // the jdk will ignore the origin character and cast it to '?'
- // this acts the same with jdk
- return defaultEncodeUTF8(str, bytes);
- } else {
- uc = c;
- }
- }
-
- if (uc < 0) {
- bytes[dp++] = (byte) '?';
- } else {
- bytes[dp++] = (byte) (0xf0 | ((uc >> 18)));
- bytes[dp++] = (byte) (0x80 | ((uc >> 12) & 0x3f));
- bytes[dp++] = (byte) (0x80 | ((uc >> 6) & 0x3f));
- bytes[dp++] = (byte) (0x80 | (uc & 0x3f));
- offset++; // 2 chars
- }
- } else {
- // 3 bytes, 16 bits
- bytes[dp++] = (byte) (0xe0 | ((c >> 12)));
- bytes[dp++] = (byte) (0x80 | ((c >> 6) & 0x3f));
- bytes[dp++] = (byte) (0x80 | (c & 0x3f));
- }
- }
- return dp;
- }
-
- static int defaultEncodeUTF8(String str, byte[] bytes) {
- try {
- byte[] buffer = str.getBytes("UTF-8");
- System.arraycopy(buffer, 0, bytes, 0, buffer.length);
- return buffer.length;
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("encodeUTF8 error", e);
- }
- }
-
- static final int TAG_TYPE_BITS = 3;
-
- static int makeTag(final int fieldNumber, final int wireType) {
- return (fieldNumber << TAG_TYPE_BITS) | wireType;
- }
-
- static int getWireFormatForFieldType(final WireFormat.FieldType type, boolean isPacked) {
- if (isPacked) {
- return WireFormat.WIRETYPE_LENGTH_DELIMITED;
- } else {
- return type.getWireType();
- }
- }
-
- static int computeLengthDelimitedFieldSize(int fieldLength) {
- return CodedOutputStream.computeUInt32SizeNoTag(fieldLength) + fieldLength;
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.WireFormat;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+
+public class ProtobufSerializer {
+ final MessageData messageData;
+
+ public ProtobufSerializer(Descriptor descriptor) {
+ ProtobufUtils.checkSupportParseDescriptor(descriptor);
+ messageData = new MessageData(descriptor);
+ }
+
+ public byte[] serialize(Map<String, Object> data) throws Exception {
+ messageData.feed(data);
+ byte[] result = new byte[messageData.getSerializedSize()];
+ CodedOutputStream output = CodedOutputStream.newInstance(result);
+ messageData.writeTo(output);
+ output.checkNoSpaceLeft();
+ return result;
+ }
+
+ static double convertToDouble(Object obj) throws Exception {
+ if (obj instanceof Double) {
+ return (Double) obj;
+ } else if (obj instanceof Number) {
+ return ((Number) obj).doubleValue();
+ } else if (obj instanceof String) {
+ return Double.parseDouble((String) obj);
+ } else {
+ throw new IllegalArgumentException("can not convert to double");
+ }
+ }
+
+ static float convertToFloat(Object obj) throws Exception {
+ if (obj instanceof Float) {
+ return (Float) obj;
+ } else if (obj instanceof Number) {
+ return ((Number) obj).floatValue();
+ } else if (obj instanceof String) {
+ return Float.parseFloat((String) obj);
+ } else {
+ throw new IllegalArgumentException("can not convert to double");
+ }
+ }
+
+ static int convertToInt(Object obj) throws Exception {
+ if (obj instanceof Integer) {
+ return (Integer) obj;
+ } else if (obj instanceof Number) {
+ return ((Number) obj).intValue();
+ } else if (obj instanceof String) {
+ return Integer.parseInt((String) obj);
+ } else {
+ throw new IllegalArgumentException("can not convert to double");
+ }
+ }
+
+ static long convertToLong(Object obj) throws Exception {
+ if (obj instanceof Long) {
+ return (Long) obj;
+ } else if (obj instanceof Number) {
+ return ((Number) obj).longValue();
+ } else if (obj instanceof String) {
+ return Long.parseLong((String) obj);
+ } else {
+ throw new IllegalArgumentException("can not convert to long:" + obj);
+ }
+ }
+
+ static boolean convertToBool(Object obj) throws Exception {
+ if (obj instanceof Boolean) {
+ return (Boolean) obj;
+ } else if (obj instanceof Number) {
+ return ((Number) obj).intValue() != 0;
+ } else {
+ throw new IllegalArgumentException("can not convert to double");
+ }
+ }
+
+ static class MessageData extends ProtobufData {
+ final FieldData[] fieldDatas;
+ final Map<String, FieldData> fieldDataMap;
+ int memoizedSize = -1;
+
+ public MessageData(Descriptor descriptor) {
+ List<FieldDescriptor> fields = descriptor.getFields();
+ fieldDatas = new FieldData[fields.size()];
+ fieldDataMap = new HashMap<>();
+ for (int i = 0; i < fields.size(); i++) {
+ fieldDatas[i] = FieldData.newInstance(fields.get(i));
+ fieldDataMap.put(fieldDatas[i].name, fieldDatas[i]);
+ }
+ }
+
+ @Override
+ public int getSerializedSize() {
+ if(memoizedSize != -1){
+ return memoizedSize;
+ }
+
+ int size = 0;
+ FieldData fieldData;
+ for (int i = 0; i < fieldDatas.length; i++) {
+ fieldData = fieldDatas[i];
+ if (fieldData.isNotNull()) {
+ size += fieldData.getSerializedSize();
+ //System.out.println(fieldData.name + " -> " + size);
+ }
+ }
+
+ memoizedSize = size;
+ return size;
+ }
+
+ @Override
+ public boolean feed(Object obj) throws Exception {
+ memoizedSize = -1;
+ Map<String, Object> map = (Map<String, Object>) obj;
+ FieldData fieldData;
+ for (int i = 0; i < fieldDatas.length; i++) {
+ fieldData = fieldDatas[i];
+ fieldData.reset();
+ }
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
+ fieldData = fieldDataMap.get(entry.getKey());
+ if(fieldData != null) {
+ Object value = entry.getValue();
+ if (value != null) {
+ fieldData.feed(value);
+ }
+ }
+ }
+ return true;
+ }
+
+ /*@Override
+ public boolean feed(Object obj) throws Exception {
+ memoizedSize = -1;
+ Map<String, Object> map = (Map<String, Object>) obj;
+ FieldData fieldData;
+ for (int i = 0; i < fieldDatas.length; i++) {
+ fieldData = fieldDatas[i];
+ fieldData.reset();
+ Object value = map.get(fieldData.name);
+ if (value != null) {
+ fieldData.feed(value);
+ }
+ }
+ return true;
+ }*/
+
+ @Override
+ public void writeTo(CodedOutputStream output) throws Exception {
+ FieldData fieldData;
+ for (int i = 0; i < fieldDatas.length; i++) {
+ fieldData = fieldDatas[i];
+ if (fieldData.isNotNull()) {
+ fieldData.writeTo(output);
+ //System.out.println(fieldData.name + " -> " + output.spaceLeft());
+ }
+ }
+ }
+ }
+
+ static abstract class FieldData {
+ final int tag;
+ final int tagSize;
+ final FieldDescriptor field;
+
+ final String name;
+ final boolean message;
+ final boolean optional;
+ final boolean packed;
+ final boolean repeated;
+
+ FieldData(int tag, int tagSize, FieldDescriptor field) {
+ this.tag = tag;
+ this.tagSize = tagSize;
+ this.field = field;
+ this.name = field.getName();
+ this.message = field.getType() == FieldDescriptor.Type.MESSAGE;
+ this.optional = field.hasOptionalKeyword();
+ this.packed = field.isPacked();
+ this.repeated = field.isRepeated();
+ }
+
+ abstract void reset();
+
+ abstract boolean isNotNull();
+
+ abstract int getSerializedSize();
+
+ abstract void feed(Object obj) throws Exception;
+
+ abstract void writeTo(CodedOutputStream output) throws Exception;
+
+ static FieldData newInstance(FieldDescriptor field) {
+ WireFormat.FieldType type = field.getLiteType();
+ int tag = makeTag(field.getNumber(), getWireFormatForFieldType(type, field.isPacked()));
+ int tagSize = CodedOutputStream.computeTagSize(field.getNumber());
+ Supplier<ProtobufData> dataSupplier = getProtobufDataSupplier(field);
+ if (field.isRepeated()) {
+ return new ArrayFieldData(tag, tagSize, field, dataSupplier);
+ } else {
+ return new ValueFieldData(tag, tagSize, field, dataSupplier.get());
+ }
+ }
+
+ static Supplier<ProtobufData> getProtobufDataSupplier(FieldDescriptor field) {
+ switch (field.getLiteType()) {
+ case DOUBLE:
+ return () -> new DoubleData();
+ case FLOAT:
+ return () -> new FloatData();
+ case INT64:
+ return () -> new Int64Data();
+ case UINT64:
+ return () -> new Uint64Data();
+ case FIXED64:
+ return () -> new Fixed64Data();
+ case SFIXED64:
+ return () -> new SFixed64Data();
+ case SINT64:
+ return () -> new SInt64Data();
+ case INT32:
+ return () -> new Int32Data();
+ case UINT32:
+ return () -> new Uint32Data();
+ case FIXED32:
+ return () -> new Fixed32Data();
+ case SFIXED32:
+ return () -> new SFixed32Data();
+ case SINT32:
+ return () -> new SInt32Data();
+ case STRING:
+ return () -> new StringData();
+ case BYTES:
+ return () -> new BytesData();
+ case BOOL:
+ return () -> new BoolData();
+ case MESSAGE:
+ return () -> new MessageData(field.getMessageType());
+ case ENUM:
+ int number = ((EnumValueDescriptor) field.getDefaultValue()).getNumber();
+ return () -> new EnumData(number);
+ default:
+ throw new IllegalArgumentException(String.format("not supported type:%s(%s)", field.getType(), field.getName()));
+ }
+ }
+ }
+
+ static class ValueFieldData extends FieldData {
+ final ProtobufData data;
+ boolean notNull = false;
+
+ ValueFieldData(int tag, int tagSize, FieldDescriptor field, ProtobufData data) {
+ super(tag, tagSize, field);
+ this.data = data;
+ }
+
+ @Override
+ void reset() {
+ notNull = false;
+ }
+
+ @Override
+ boolean isNotNull() {
+ return notNull;
+ }
+
+ @Override
+ int getSerializedSize() {
+ if (message) {
+ return tagSize + computeLengthDelimitedFieldSize(data.getSerializedSize());
+ } else {
+ return tagSize + data.getSerializedSize();
+ }
+ }
+
+ @Override
+ void feed(Object obj) throws Exception {
+ notNull = data.feed(obj);
+ if(optional){
+ notNull = true;
+ }
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ // com.geedgenetworks.shaded.com.google.protobuf.FieldSet.writeElement
+ output.writeUInt32NoTag(tag);
+ if (message) {
+ output.writeUInt32NoTag(data.getSerializedSize());
+ }
+ data.writeTo(output);
+ }
+ }
+
+ static class ArrayFieldData extends FieldData {
+ final List<ProtobufData> datas;
+ private int pos = 0;
+ int dataSize = 0;
+ final Supplier<ProtobufData> dataSupplier;
+
+ ArrayFieldData(int tag, int tagSize, FieldDescriptor field, Supplier<ProtobufData> dataSupplier) {
+ super(tag, tagSize, field);
+ this.datas = new ArrayList<>();
+ this.dataSupplier = dataSupplier;
+ }
+
+ @Override
+ void reset() {
+ pos = 0;
+ }
+
+ @Override
+ boolean isNotNull() {
+ return pos != 0;
+ }
+
+ @Override
+ int getSerializedSize() {
+ // com.geedgenetworks.shaded.com.google.protobuf.FieldSet.computeFieldSize
+ if (packed) {
+ int size = 0;
+ for (int i = 0; i < pos; i++) {
+ size += message ? computeLengthDelimitedFieldSize(datas.get(i).getSerializedSize()) : datas.get(i).getSerializedSize();
+ }
+ dataSize = size;
+ size += CodedOutputStream.computeUInt32SizeNoTag(size);
+ return tagSize + size;
+ } else {
+ int size = 0;
+ for (int i = 0; i < pos; i++) {
+ size += tagSize;
+ size += message ? computeLengthDelimitedFieldSize(datas.get(i).getSerializedSize()) : datas.get(i).getSerializedSize();
+ }
+ return size;
+ }
+ }
+
+ @Override
+ void feed(Object obj) throws Exception {
+ List<Object> list = (List<Object>) obj;
+ ProtobufData data;
+ if(datas.size() < list.size()){
+ int len = list.size() - datas.size();
+ for (int i = 0; i < len; i++) {
+ datas.add(dataSupplier.get());
+ }
+ }
+ for (int i = 0; i < list.size(); i++) {
+ data = datas.get(i);
+ data.feed(list.get(i));
+ }
+ pos = list.size();
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ //com.geedgenetworks.shaded.com.google.protobuf.FieldSet.writeField
+ if (packed) {
+ output.writeUInt32NoTag(tag);
+ output.writeUInt32NoTag(dataSize);
+ for (int i = 0; i < pos; i++) {
+ datas.get(i).writeTo(output);
+ }
+ } else {
+ for (int i = 0; i < pos; i++) {
+ output.writeUInt32NoTag(tag);
+ if(message){
+ output.writeUInt32NoTag(datas.get(i).getSerializedSize());
+ }
+ datas.get(i).writeTo(output);
+ }
+ }
+ }
+ }
+
+ static class DoubleData extends ProtobufData {
+ private double value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeDoubleSizeNoTag(value); // FIXED64_SIZE
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToDouble(obj);
+ return value != 0D;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeDoubleNoTag(value);
+ }
+ }
+
+ static class FloatData extends ProtobufData {
+ private float value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeFloatSizeNoTag(value); // FIXED32_SIZE
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToFloat(obj);
+ return value != 0F;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeFloatNoTag(value);
+ }
+ }
+
+
+ static class Int32Data extends ProtobufData {
+ private int value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeInt32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeInt32NoTag(value);
+ }
+ }
+
+ static class Uint32Data extends ProtobufData {
+ private int value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeInt32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeUInt32NoTag(value);
+ }
+ }
+
+ static class Fixed32Data extends ProtobufData {
+ private int value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeFixed32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeFixed32NoTag(value);
+ }
+ }
+
+ static class SFixed32Data extends ProtobufData {
+ private int value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeSFixed32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeSFixed32NoTag(value);
+ }
+ }
+
+ static class SInt32Data extends ProtobufData {
+ private int value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeSInt32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeSInt32NoTag(value);
+ }
+ }
+
+ static class Int64Data extends ProtobufData {
+ private long value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeInt64SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToLong(obj);
+ return value != 0L;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeInt64NoTag(value);
+ }
+ }
+
+ static class Uint64Data extends ProtobufData {
+ private long value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeInt64SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToLong(obj);
+ return value != 0L;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeUInt64NoTag(value);
+ }
+ }
+
+ static class Fixed64Data extends ProtobufData {
+ private long value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeFixed64SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToLong(obj);
+ return value != 0L;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeFixed64NoTag(value);
+ }
+ }
+
+ static class SFixed64Data extends ProtobufData {
+ private long value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeSFixed64SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToLong(obj);
+ return value != 0L;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeSFixed64NoTag(value);
+ }
+ }
+
+ static class SInt64Data extends ProtobufData {
+ private long value;
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeSInt64SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToLong(obj);
+ return value != 0L;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeSInt64NoTag(value);
+ }
+ }
+
+ static final int MAX_STR_BYTES_LENGTH = 1024 * 12;
+ static class StringData extends ProtobufData {
+ private final byte[] bytes = new byte[MAX_STR_BYTES_LENGTH];
+ private byte[] value;
+ private int len;
+
+ @Override
+ int getSerializedSize() {
+ return computeLengthDelimitedFieldSize(len);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ String str = obj.toString();
+ if(str.isEmpty()){
+ value = bytes;
+ len = 0;
+ return false;
+ }
+ //value = str.getBytes(StandardCharsets.UTF_8);
+ int length = str.length() * 3;
+ if (length > MAX_STR_BYTES_LENGTH) {
+ value = new byte[length];
+ }else{
+ value = bytes;
+ }
+
+ len = encodeUTF8(str, value);
+ return true;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeUInt32NoTag(len);
+ output.write(value, 0, len);
+ }
+ }
+
+ static class BytesData extends ProtobufData {
+ private byte[] value;
+
+ @Override
+ int getSerializedSize() {
+ return computeLengthDelimitedFieldSize(value.length);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = (byte[]) obj;
+ return value.length != 0;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeByteArrayNoTag(value);
+ }
+ }
+
+ static class BoolData extends ProtobufData {
+ private boolean value;
+
+ @Override
+ int getSerializedSize() {
+ return 1;
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToBool(obj);
+ return value;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeBoolNoTag(value);
+ }
+ }
+
+ static class EnumData extends ProtobufData {
+ private int value;
+ final private int defaultValue;
+
+ public EnumData(int defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ int getSerializedSize() {
+ return CodedOutputStream.computeInt32SizeNoTag(value);
+ }
+
+ @Override
+ boolean feed(Object obj) throws Exception {
+ value = convertToInt(obj);
+ return value != defaultValue;
+ }
+
+ @Override
+ void writeTo(CodedOutputStream output) throws Exception {
+ output.writeInt32NoTag(value);
+ }
+ }
+
+ static abstract class ProtobufData {
+ abstract int getSerializedSize();
+
+ abstract boolean feed(Object obj) throws Exception;
+
+ abstract void writeTo(CodedOutputStream output) throws Exception;
+ }
+
+ // copy from org.apache.flink.table.runtime.util.StringUtf8Utils
+ static int encodeUTF8(String str, byte[] bytes) {
+ int offset = 0;
+ int len = str.length();
+ int sl = offset + len;
+ int dp = 0;
+ int dlASCII = dp + Math.min(len, bytes.length);
+
+ // ASCII only optimized loop
+ while (dp < dlASCII && str.charAt(offset) < '\u0080') {
+ bytes[dp++] = (byte) str.charAt(offset++);
+ }
+
+ while (offset < sl) {
+ char c = str.charAt(offset++);
+ if (c < 0x80) {
+ // Have at most seven bits
+ bytes[dp++] = (byte) c;
+ } else if (c < 0x800) {
+ // 2 bytes, 11 bits
+ bytes[dp++] = (byte) (0xc0 | (c >> 6));
+ bytes[dp++] = (byte) (0x80 | (c & 0x3f));
+ } else if (Character.isSurrogate(c)) {
+ final int uc;
+ int ip = offset - 1;
+ if (Character.isHighSurrogate(c)) {
+ if (sl - ip < 2) {
+ uc = -1;
+ } else {
+ char d = str.charAt(ip + 1);
+ if (Character.isLowSurrogate(d)) {
+ uc = Character.toCodePoint(c, d);
+ } else {
+ // for some illegal character
+ // the jdk will ignore the origin character and cast it to '?'
+ // this acts the same with jdk
+ return defaultEncodeUTF8(str, bytes);
+ }
+ }
+ } else {
+ if (Character.isLowSurrogate(c)) {
+ // for some illegal character
+ // the jdk will ignore the origin character and cast it to '?'
+ // this acts the same with jdk
+ return defaultEncodeUTF8(str, bytes);
+ } else {
+ uc = c;
+ }
+ }
+
+ if (uc < 0) {
+ bytes[dp++] = (byte) '?';
+ } else {
+ bytes[dp++] = (byte) (0xf0 | ((uc >> 18)));
+ bytes[dp++] = (byte) (0x80 | ((uc >> 12) & 0x3f));
+ bytes[dp++] = (byte) (0x80 | ((uc >> 6) & 0x3f));
+ bytes[dp++] = (byte) (0x80 | (uc & 0x3f));
+ offset++; // 2 chars
+ }
+ } else {
+ // 3 bytes, 16 bits
+ bytes[dp++] = (byte) (0xe0 | ((c >> 12)));
+ bytes[dp++] = (byte) (0x80 | ((c >> 6) & 0x3f));
+ bytes[dp++] = (byte) (0x80 | (c & 0x3f));
+ }
+ }
+ return dp;
+ }
+
+ static int defaultEncodeUTF8(String str, byte[] bytes) {
+ try {
+ byte[] buffer = str.getBytes("UTF-8");
+ System.arraycopy(buffer, 0, bytes, 0, buffer.length);
+ return buffer.length;
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("encodeUTF8 error", e);
+ }
+ }
+
+ static final int TAG_TYPE_BITS = 3;
+
+ static int makeTag(final int fieldNumber, final int wireType) {
+ return (fieldNumber << TAG_TYPE_BITS) | wireType;
+ }
+
+ static int getWireFormatForFieldType(final WireFormat.FieldType type, boolean isPacked) {
+ if (isPacked) {
+ return WireFormat.WIRETYPE_LENGTH_DELIMITED;
+ } else {
+ return type.getWireType();
+ }
+ }
+
+ static int computeLengthDelimitedFieldSize(int fieldLength) {
+ return CodedOutputStream.computeUInt32SizeNoTag(fieldLength) + fieldLength;
+ }
+}
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufUtils.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufUtils.java
index 3152ce0..0b7cd28 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufUtils.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/ProtobufUtils.java
@@ -1,86 +1,86 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.google.protobuf.AnyProto;
-import com.google.protobuf.DescriptorProtos;
-import com.google.protobuf.Descriptors.Descriptor;
-import com.google.protobuf.Descriptors.FileDescriptor;
-import com.google.protobuf.ProtocolStringList;
-import org.apache.commons.io.FileUtils;
-import org.apache.flink.util.Preconditions;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-public class ProtobufUtils {
-
- public static boolean isProto3(Descriptor descriptor){
- return descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO3;
- }
-
- public static boolean isMessageSetWireFormat(Descriptor descriptor){
- return descriptor.getOptions().getMessageSetWireFormat();
- }
-
- public static void checkSupportParseDescriptor(Descriptor descriptor){
- Preconditions.checkArgument(isProto3(descriptor), "only support proto3");
- Preconditions.checkArgument(!isMessageSetWireFormat(descriptor), "not support message_set_wire_format option");
- }
-
- public static byte[] readDescriptorFileContent(String filePath) {
- try {
- return FileUtils.readFileToByteArray(new File(filePath));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static Descriptor buildDescriptor(byte[] bytes, String messageName) throws Exception{
- List<FileDescriptor> fileDescriptorList = parseFileDescriptorSet(bytes);
- Optional<Descriptor> optionalDescriptor = fileDescriptorList.stream().flatMap(fileDesc -> {
- return fileDesc.getMessageTypes().stream().filter(desc -> desc.getName().equals(messageName) || desc.getFullName().equals(messageName));
- }).findFirst();
- if(!optionalDescriptor.isPresent()){
- throw new IllegalArgumentException("not found messageName:" + messageName);
- }
- return optionalDescriptor.get();
- }
-
- private static List<FileDescriptor> parseFileDescriptorSet(byte[] bytes) throws Exception{
- DescriptorProtos.FileDescriptorSet fileDescriptorSet = DescriptorProtos.FileDescriptorSet.parseFrom(bytes);
- Map<String, DescriptorProtos.FileDescriptorProto> fileDescriptorProtoMap = fileDescriptorSet.getFileList().stream().collect(Collectors.toMap(x -> x.getName(), x -> x));
- List<FileDescriptor> fileDescriptorList = new ArrayList<>();
- for (DescriptorProtos.FileDescriptorProto fileDescriptorProto : fileDescriptorSet.getFileList()) {
- FileDescriptor fileDescriptor = buildFileDescriptor(fileDescriptorProto, fileDescriptorProtoMap);
- fileDescriptorList.add(fileDescriptor);
- }
- return fileDescriptorList;
- }
-
- private static FileDescriptor buildFileDescriptor(DescriptorProtos.FileDescriptorProto fileDescriptorProto, Map<String, DescriptorProtos.FileDescriptorProto> fileDescriptorProtoMap) throws Exception{
- ProtocolStringList dependencyList = fileDescriptorProto.getDependencyList();
- FileDescriptor[] fileDescriptorArray = new FileDescriptor[dependencyList.size()];
- for (int i = 0; i < fileDescriptorArray.length; i++) {
- String dependency = dependencyList.get(i);
- DescriptorProtos.FileDescriptorProto dependencyProto = fileDescriptorProtoMap.get(dependency);
- if (dependencyProto == null) {
- throw new IllegalArgumentException("dependency:" + dependency + "not exist");
- }
- if (dependencyProto.getName().equals("google/protobuf/any.proto")
- && dependencyProto.getPackage().equals("google.protobuf")) {
- // For Any, use the descriptor already included as part of the Java dependency.
- // Without this, JsonFormat used for converting Any fields fails when
- // an Any field in input is set to `Any.getDefaultInstance()`.
- fileDescriptorArray[i] = AnyProto.getDescriptor();
- } else {
- fileDescriptorArray[i] = buildFileDescriptor(dependencyProto, fileDescriptorProtoMap);
- }
- }
-
- return FileDescriptor.buildFrom(fileDescriptorProto, fileDescriptorArray);
- }
+package com.geedgenetworks.formats.protobuf;
+
+import com.geedgenetworks.shaded.com.google.protobuf.AnyProto;
+import com.geedgenetworks.shaded.com.google.protobuf.DescriptorProtos;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FileDescriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.ProtocolStringList;
+import org.apache.commons.io.FileUtils;
+import org.apache.flink.util.Preconditions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class ProtobufUtils {
+
+ public static boolean isProto3(Descriptor descriptor){
+ return descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO3;
+ }
+
+ public static boolean isMessageSetWireFormat(Descriptor descriptor){
+ return descriptor.getOptions().getMessageSetWireFormat();
+ }
+
+ public static void checkSupportParseDescriptor(Descriptor descriptor){
+ Preconditions.checkArgument(isProto3(descriptor), "only support proto3");
+ Preconditions.checkArgument(!isMessageSetWireFormat(descriptor), "not support message_set_wire_format option");
+ }
+
+ public static byte[] readDescriptorFileContent(String filePath) {
+ try {
+ return FileUtils.readFileToByteArray(new File(filePath));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Descriptor buildDescriptor(byte[] bytes, String messageName) throws Exception{
+ List<FileDescriptor> fileDescriptorList = parseFileDescriptorSet(bytes);
+ Optional<Descriptor> optionalDescriptor = fileDescriptorList.stream().flatMap(fileDesc -> {
+ return fileDesc.getMessageTypes().stream().filter(desc -> desc.getName().equals(messageName) || desc.getFullName().equals(messageName));
+ }).findFirst();
+ if(!optionalDescriptor.isPresent()){
+ throw new IllegalArgumentException("not found messageName:" + messageName);
+ }
+ return optionalDescriptor.get();
+ }
+
+ private static List<FileDescriptor> parseFileDescriptorSet(byte[] bytes) throws Exception{
+ DescriptorProtos.FileDescriptorSet fileDescriptorSet = DescriptorProtos.FileDescriptorSet.parseFrom(bytes);
+ Map<String, DescriptorProtos.FileDescriptorProto> fileDescriptorProtoMap = fileDescriptorSet.getFileList().stream().collect(Collectors.toMap(x -> x.getName(), x -> x));
+ List<FileDescriptor> fileDescriptorList = new ArrayList<>();
+ for (DescriptorProtos.FileDescriptorProto fileDescriptorProto : fileDescriptorSet.getFileList()) {
+ FileDescriptor fileDescriptor = buildFileDescriptor(fileDescriptorProto, fileDescriptorProtoMap);
+ fileDescriptorList.add(fileDescriptor);
+ }
+ return fileDescriptorList;
+ }
+
+ private static FileDescriptor buildFileDescriptor(DescriptorProtos.FileDescriptorProto fileDescriptorProto, Map<String, DescriptorProtos.FileDescriptorProto> fileDescriptorProtoMap) throws Exception{
+ ProtocolStringList dependencyList = fileDescriptorProto.getDependencyList();
+ FileDescriptor[] fileDescriptorArray = new FileDescriptor[dependencyList.size()];
+ for (int i = 0; i < fileDescriptorArray.length; i++) {
+ String dependency = dependencyList.get(i);
+ DescriptorProtos.FileDescriptorProto dependencyProto = fileDescriptorProtoMap.get(dependency);
+ if (dependencyProto == null) {
+ throw new IllegalArgumentException("dependency:" + dependency + "not exist");
+ }
+ if (dependencyProto.getName().equals("google/protobuf/any.proto")
+ && dependencyProto.getPackage().equals("google.protobuf")) {
+ // For Any, use the descriptor already included as part of the Java dependency.
+ // Without this, JsonFormat used for converting Any fields fails when
+ // an Any field in input is set to `Any.getDefaultInstance()`.
+ fileDescriptorArray[i] = AnyProto.getDescriptor();
+ } else {
+ fileDescriptorArray[i] = buildFileDescriptor(dependencyProto, fileDescriptorProtoMap);
+ }
+ }
+
+ return FileDescriptor.buildFrom(fileDescriptorProto, fileDescriptorArray);
+ }
} \ No newline at end of file
diff --git a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/SchemaConverters.java b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/SchemaConverters.java
index 95a2e9c..196b0c9 100644
--- a/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/SchemaConverters.java
+++ b/groot-formats/format-protobuf/src/main/java/com/geedgenetworks/formats/protobuf/SchemaConverters.java
@@ -1,807 +1,807 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.google.protobuf.Descriptors;
-import com.geedgenetworks.core.types.*;
-import com.geedgenetworks.core.types.StructType.StructField;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.Descriptors.Descriptor;
-import com.google.protobuf.Descriptors.FieldDescriptor;
-import com.google.protobuf.WireFormat;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.flink.util.Preconditions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.stream.Collectors;
-
-public class SchemaConverters {
- static final Logger LOG = LoggerFactory.getLogger(SchemaConverters.class);
- public static StructType toStructType(Descriptor descriptor) {
- StructField[] fields = descriptor.getFields().stream().map(f -> structFieldFor(f)).toArray(StructField[]::new);
- return new StructType(fields);
- }
-
- private static StructField structFieldFor(FieldDescriptor fd) {
- WireFormat.FieldType type = fd.getLiteType();
- DataType dataType;
- switch (type) {
- case DOUBLE:
- dataType = Types.DOUBLE;
- break;
- case FLOAT:
- dataType = Types.FLOAT;
- break;
- case INT64:
- case UINT64:
- case FIXED64:
- case SINT64:
- case SFIXED64:
- dataType = Types.BIGINT;
- break;
- case INT32:
- case UINT32:
- case FIXED32:
- case SINT32:
- case SFIXED32:
- dataType = Types.INT;
- break;
- case BOOL:
- dataType = Types.BOOLEAN;
- break;
- case STRING:
- dataType = Types.STRING;
- break;
- case BYTES:
- dataType = Types.BINARY;
- break;
- case ENUM:
- dataType = Types.INT;
- break;
- case MESSAGE:
- if (fd.isRepeated() && fd.getMessageType().getOptions().hasMapEntry()) {
- throw new IllegalArgumentException(String.format("not supported type:%s(%s)", type, fd.getName()));
- } else {
- StructField[] fields = fd.getMessageType().getFields().stream().map(f -> structFieldFor(f)).toArray(StructField[]::new);
- dataType = new StructType(fields);
- }
- break;
- default:
- throw new IllegalArgumentException(String.format("not supported type:%s(%s)", type, fd.getName()));
- }
- if (fd.isRepeated()) {
- return new StructField(fd.getName(), new ArrayType(dataType));
- } else {
- return new StructField(fd.getName(), dataType);
- }
- }
-
- // 校验dataType和descriptor是否匹配,dataType中定义的属性必须全部在descriptor定义,每个字段的类型必须匹配(相同或者能够转换)
- public static void checkMatch(Descriptor descriptor, StructType dataType) throws Exception {
- checkMatch(descriptor, dataType, null);
- }
-
- private static void checkMatch(Descriptor descriptor, StructType dataType, String prefix) throws Exception {
- List<FieldDescriptor> fieldDescriptors = descriptor.getFields();
- Map<String, FieldDescriptor> fdMap = fieldDescriptors.stream().collect(Collectors.toMap(x -> x.getName(), x -> x));
- StructField[] fields = dataType.fields;
-
- for (int i = 0; i < fields.length; i++) {
- StructField field = fields[i];
- FieldDescriptor fd = fdMap.get(field.name);
- if(fd == null){
- throw new IllegalArgumentException(String.format("%s ' field:%s not found in proto descriptor", StringUtils.isBlank(prefix)? "root": prefix, field));
- }
- WireFormat.FieldType type = fd.getLiteType();
- DataType fieldDataType;
- if(fd.isRepeated()){
- if(!(field.dataType instanceof ArrayType)){
- throw newNotMatchException(field, fd, prefix);
- }
- fieldDataType = ((ArrayType)field.dataType).elementType;
- }else{
- fieldDataType = field.dataType;
- }
- switch (type) {
- case DOUBLE:
- case FLOAT:
- if(!(fieldDataType instanceof DoubleType || fieldDataType instanceof FloatType
- || fieldDataType instanceof IntegerType || fieldDataType instanceof LongType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case INT64:
- case UINT64:
- case FIXED64:
- case SINT64:
- case SFIXED64:
- if(!(fieldDataType instanceof IntegerType || fieldDataType instanceof LongType
- || fieldDataType instanceof FloatType || fieldDataType instanceof DoubleType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case INT32:
- case UINT32:
- case FIXED32:
- case SINT32:
- case SFIXED32:
- if(!(fieldDataType instanceof IntegerType || fieldDataType instanceof LongType
- || fieldDataType instanceof FloatType || fieldDataType instanceof DoubleType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case BOOL:
- if(!(fieldDataType instanceof BooleanType || fieldDataType instanceof IntegerType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case STRING:
- if(!(fieldDataType instanceof StringType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case BYTES:
- if(!(fieldDataType instanceof BinaryType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case ENUM:
- if(!(fieldDataType instanceof IntegerType)){
- throw newNotMatchException(field, fd, prefix);
- }
- break;
- case MESSAGE:
- if(!(fieldDataType instanceof StructType)){
- throw newNotMatchException(field, fd, prefix);
- }
- checkMatch(fd.getMessageType(), (StructType) fieldDataType, StringUtils.isBlank(prefix)? field.name: prefix + "." + field.name);
- }
- }
- }
-
- private static IllegalArgumentException newNotMatchException(StructField field, FieldDescriptor fd, String prefix){
- return new IllegalArgumentException(String.format("%s ' field:%s not match with proto field descriptor:%s(%s)", StringUtils.isBlank(prefix)? "root": prefix, field, fd, fd.getType()));
- }
-
- public static class MessageConverter {
- private static final int MAX_CHARS_LENGTH = 1024 * 4;
- FieldDesc[] fieldDescArray; // Message类型对应FieldDesc, 下标为field number
- int initialCapacity = 0;
- final boolean emitDefaultValues;
- final DefaultValue[] defaultValues;
- private final char[] tmpDecodeChars = new char[MAX_CHARS_LENGTH]; // 同一个Message的转换是在一个线程内,fieldDesc共用一个临时chars
-
- public MessageConverter(Descriptor descriptor, StructType dataType, boolean emitDefaultValues) {
- ProtobufUtils.checkSupportParseDescriptor(descriptor);
- List<FieldDescriptor> fields = descriptor.getFields();
- int maxNumber = fields.stream().mapToInt(f -> f.getNumber()).max().getAsInt();
- Preconditions.checkArgument(maxNumber < 10000, maxNumber);
- fieldDescArray = new FieldDesc[maxNumber + 1];
-
- this.emitDefaultValues = emitDefaultValues;
- if(this.emitDefaultValues){
- defaultValues = new DefaultValue[dataType.fields.length];
- }else{
- defaultValues = null;
- }
-
- for (FieldDescriptor field : fields) {
- // Optional<StructField> structFieldOptional = Arrays.stream(dataType.fields).filter(f -> f.name.equals(field.getName())).findFirst();
- // if(structFieldOptional.isPresent()){
- int position = -1;
- for (int i = 0; i < dataType.fields.length; i++) {
- if(dataType.fields[i].name.equals(field.getName())){
- position = i;
- break;
- }
- }
- if(position >= 0){
- fieldDescArray[field.getNumber()] = new FieldDesc(field, dataType.fields[position].dataType, position, emitDefaultValues, tmpDecodeChars);
- if(this.emitDefaultValues){
- defaultValues[position] = new DefaultValue(dataType.fields[position].name, getDefaultValue(field, dataType.fields[position].dataType));
- }
- }
- }
- if(dataType.fields.length / 3 > 16){
- initialCapacity = (dataType.fields.length / 3) ;
- }
- if(this.emitDefaultValues){
- LOG.warn("enable emitDefaultValues will seriously affect performance !!!");
- for (int i = 0; i < defaultValues.length; i++) {
- if (defaultValues[i] == null) {
- throw new IllegalArgumentException(String.format("%s and %s not match", dataType, descriptor));
- }
- }
- }
- }
-
- public Map<String, Object> converter(byte[] bytes) throws Exception {
- CodedInputStream input = CodedInputStream.newInstance(bytes);
- return emitDefaultValues ? converterEmitDefaultValues(input): converterNoEmitDefaultValues(input);
- }
-
- public Map<String, Object> converter(CodedInputStream input) throws Exception {
- return emitDefaultValues ? converterEmitDefaultValues(input): converterNoEmitDefaultValues(input);
- }
-
- private Map<String, Object> converterNoEmitDefaultValues(CodedInputStream input) throws Exception {
- Map<String, Object> data = initialCapacity == 0? new HashMap<>(): new HashMap<>(initialCapacity);
-
- while (true) {
- int tag = input.readTag();
- if (tag == 0) {
- break;
- }
-
- final int wireType = WireFormat.getTagWireType(tag);
- final int fieldNumber = WireFormat.getTagFieldNumber(tag);
-
- FieldDesc fieldDesc = null;
- if (fieldNumber < fieldDescArray.length) {
- fieldDesc = fieldDescArray[fieldNumber];
- }
-
- boolean unknown = false;
- boolean packed = false;
- if (fieldDesc == null) {
- unknown = true; // Unknown field.
- } else if (wireType == fieldDesc.field.getLiteType().getWireType()) {
- packed = false;
- } else if (fieldDesc.field.isPackable() && wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
- packed = true;
- } else {
- unknown = true; // Unknown wire type.
- }
-
- if (unknown) { // Unknown field or wrong wire type. Skip.
- input.skipField(tag);
- continue;
- }
-
- String name = fieldDesc.name;
- if (packed) {
- final int length = input.readRawVarint32();
- final int limit = input.pushLimit(length);
- List<Object> array = (List<Object>) fieldDesc.valueConverter.convert(input, true);
- input.popLimit(limit);
- List<Object> oldArray = (List<Object>)data.get(name);
- if(oldArray == null){
- data.put(name, array);
- }else{
- oldArray.addAll(array);
- }
- } else {
- final Object value = fieldDesc.valueConverter.convert(input, false);
- if(!fieldDesc.field.isRepeated()){
- data.put(name, value);
- }else{
- List<Object> array = (List<Object>)data.get(name);
- if(array == null){
- array = new ArrayList<>();
- data.put(name, array);
- }
- array.add(value);
- }
- }
-
- }
-
- return data;
- }
- private Map<String, Object> converterEmitDefaultValues(CodedInputStream input) throws Exception {
- Map<String, Object> data = initialCapacity == 0? new HashMap<>(): new HashMap<>(initialCapacity);
-
- // 比converterNoEmitDefaultValues多的代码
- for (int i = 0; i < defaultValues.length; i++) {
- defaultValues[i].hasValue = false;
- }
-
- while (true) {
- int tag = input.readTag();
- if (tag == 0) {
- break;
- }
-
- final int wireType = WireFormat.getTagWireType(tag);
- final int fieldNumber = WireFormat.getTagFieldNumber(tag);
-
- FieldDesc fieldDesc = null;
- if (fieldNumber < fieldDescArray.length) {
- fieldDesc = fieldDescArray[fieldNumber];
- }
-
- boolean unknown = false;
- boolean packed = false;
- if (fieldDesc == null) {
- unknown = true; // Unknown field.
- } else if (wireType == fieldDesc.field.getLiteType().getWireType()) {
- packed = false;
- } else if (fieldDesc.field.isPackable() && wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
- packed = true;
- } else {
- unknown = true; // Unknown wire type.
- }
-
- if (unknown) { // Unknown field or wrong wire type. Skip.
- input.skipField(tag);
- continue;
- }
-
- // 比converterNoEmitDefaultValues多的代码
- defaultValues[fieldDesc.fieldPosition].hasValue = true;
-
- String name = fieldDesc.name;
- if (packed) {
- final int length = input.readRawVarint32();
- final int limit = input.pushLimit(length);
- List<Object> array = (List<Object>) fieldDesc.valueConverter.convert(input, true);
- input.popLimit(limit);
- List<Object> oldArray = (List<Object>)data.get(name);
- if(oldArray == null){
- data.put(name, array);
- }else{
- oldArray.addAll(array);
- }
- } else {
- final Object value = fieldDesc.valueConverter.convert(input, false);
- if(!fieldDesc.field.isRepeated()){
- data.put(name, value);
- }else{
- List<Object> array = (List<Object>)data.get(name);
- if(array == null){
- array = new ArrayList<>();
- data.put(name, array);
- }
- array.add(value);
- }
- }
-
- }
-
- // 比converterNoEmitDefaultValues多的代码
- DefaultValue defaultValue;
- for (int i = 0; i < defaultValues.length; i++) {
- defaultValue = defaultValues[i];
- if(!defaultValue.hasValue && defaultValue.defaultValue != null){
- data.put(defaultValue.name, defaultValue.defaultValue);
- }
- }
-
- return data;
- }
-
- private Object getDefaultValue(FieldDescriptor field, DataType fieldDataType){
- if(field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE){
- return null;
- }
- if(field.isRepeated()){
- return null;
- }
- if(field.hasOptionalKeyword()){
- return null;
- }
-
- switch (field.getType()) {
- case DOUBLE:
- case FLOAT:
- case INT64:
- case UINT64:
- case FIXED64:
- case SFIXED64:
- case SINT64:
- case INT32:
- case UINT32:
- case FIXED32:
- case SFIXED32:
- case SINT32:
- Number number = 0L;
- if (fieldDataType instanceof DoubleType) {
- return number.doubleValue();
- } else if (fieldDataType instanceof FloatType) {
- return number.floatValue();
- } else if (fieldDataType instanceof IntegerType) {
- return number.intValue();
- } else if (fieldDataType instanceof LongType) {
- return number.longValue();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case BOOL:
- if (fieldDataType instanceof BooleanType) {
- return false;
- } else if (fieldDataType instanceof IntegerType) {
- return 0;
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case BYTES:
- if (fieldDataType instanceof BinaryType) {
- return new byte[0];
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case STRING:
- if (fieldDataType instanceof StringType) {
- return "";
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case ENUM:
- if (fieldDataType instanceof IntegerType) {
- return ((Descriptors.EnumValueDescriptor) field.getDefaultValue()).getNumber();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- default:
- throw new IllegalArgumentException(String.format("not supported proto type:%s(%s)", field.getType(), field.getName()));
- }
- }
- }
-
- public static class DefaultValue{
- boolean hasValue;
- final String name;
-
- final Object defaultValue;
-
- public DefaultValue(String name, Object defaultValue) {
- this.name = name;
- this.defaultValue = defaultValue;
- }
- }
-
- public static class FieldDesc {
- final FieldDescriptor field;
- final String name;
- final DataType fieldDataType; // field对应DataType,array类型存对应元素的类型
- final int fieldPosition; // field位置
-
- final ValueConverter valueConverter;
- private final char[] tmpDecodeChars;
-
- public FieldDesc(FieldDescriptor field, DataType dataType, int fieldPosition, boolean emitDefaultValues, char[] tmpDecodeChars) {
- this.field = field;
- this.name = field.getName();
- if (dataType instanceof ArrayType) {
- this.fieldDataType = ((ArrayType) dataType).elementType;
- } else {
- this.fieldDataType = dataType;
- }
- this.fieldPosition = fieldPosition;
- this.tmpDecodeChars = tmpDecodeChars;
- valueConverter = makeConverter(emitDefaultValues);
- }
-
- private ValueConverter makeConverter(boolean emitDefaultValues) {
- switch (field.getType()) {
- case ENUM:
- if(!(fieldDataType instanceof IntegerType)){
- throw newCanNotConvertException(field, fieldDataType);
- }
- return (input, packed) -> {
- if (packed) {
- List<Object> array = new ArrayList<>();
- while (input.getBytesUntilLimit() > 0) {
- array.add(input.readEnum());
- }
- return array;
- } else {
- return input.readEnum();
- }
- };
- case MESSAGE:
- final Descriptor descriptor = field.getMessageType();
- final MessageConverter messageConverter = new MessageConverter(descriptor, (StructType) fieldDataType, emitDefaultValues);
- return (input, packed) -> {
- final int length = input.readRawVarint32();
- final int oldLimit = input.pushLimit(length);
- Object message = messageConverter.converter(input);
- input.checkLastTagWas(0);
- if (input.getBytesUntilLimit() != 0) {
- throw new RuntimeException("parse");
- }
- input.popLimit(oldLimit);
- return message;
- };
- default:
- ValueConverter fieldConverter = makePrimitiveFieldConverter();
- return (input, packed) -> {
- if (packed) {
- List<Object> array = new ArrayList<>();
- while (input.getBytesUntilLimit() > 0) {
- array.add(fieldConverter.convert(input, false));
- }
- return array;
- } else {
- return fieldConverter.convert(input, false);
- }
- };
- }
- }
-
- private ValueConverter makePrimitiveFieldConverter() {
- switch (field.getType()) {
- case DOUBLE:
- if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> input.readDouble();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readDouble();
- } else if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readDouble();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readDouble();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case FLOAT:
- if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readFloat();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> input.readFloat();
- } else if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readFloat();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readFloat();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case INT64:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readInt64();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> input.readInt64();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readInt64();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readInt64();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case UINT64:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readUInt64();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> input.readUInt64();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readUInt64();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readUInt64();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case FIXED64:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readFixed64();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> input.readFixed64();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readFixed64();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readFixed64();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case SFIXED64:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readSFixed64();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> input.readSFixed64();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readSFixed64();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readSFixed64();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case SINT64:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> (int) input.readSInt64();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> input.readSInt64();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readSInt64();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readSInt64();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case INT32:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readInt32();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readInt32();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readInt32();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readInt32();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case UINT32:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readUInt32();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readUInt32();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readUInt32();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readUInt32();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case FIXED32:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readFixed32();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readFixed32();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readFixed32();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readFixed32();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case SFIXED32:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readSFixed32();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readSFixed32();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readSFixed32();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readSFixed32();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case SINT32:
- if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readSInt32();
- } else if (fieldDataType instanceof LongType) {
- return (input, packed) -> (long) input.readSInt32();
- } else if (fieldDataType instanceof FloatType) {
- return (input, packed) -> (float) input.readSInt32();
- } else if (fieldDataType instanceof DoubleType) {
- return (input, packed) -> (double) input.readSInt32();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case BOOL:
- if (fieldDataType instanceof BooleanType) {
- return (input, packed) -> input.readBool();
- } else if (fieldDataType instanceof IntegerType) {
- return (input, packed) -> input.readBool() ? 1 : 0;
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case BYTES:
- if (fieldDataType instanceof BinaryType) {
- return (input, packed) -> input.readByteArray();
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- case STRING:
- if (fieldDataType instanceof StringType) {
- return (input, packed) -> {
- //return input.readString();
- byte[] bytes = input.readByteArray();
- return decodeUTF8(bytes, 0, bytes.length);
- };
- } else {
- throw newCanNotConvertException(field, fieldDataType);
- }
- default:
- throw new IllegalArgumentException(String.format("not supported proto type:%s(%s)", field.getType(), field.getName()));
- }
- }
-
- private String decodeUTF8(byte[] input, int offset, int byteLen) {
- char[] chars = MessageConverter.MAX_CHARS_LENGTH < byteLen? new char[byteLen]: tmpDecodeChars;
- int len = decodeUTF8Strict(input, offset, byteLen, chars);
- if (len < 0) {
- return defaultDecodeUTF8(input, offset, byteLen);
- }
- return new String(chars, 0, len);
- }
-
- private static int decodeUTF8Strict(byte[] sa, int sp, int len, char[] da) {
- final int sl = sp + len;
- int dp = 0;
- int dlASCII = Math.min(len, da.length);
-
- // ASCII only optimized loop
- while (dp < dlASCII && sa[sp] >= 0) {
- da[dp++] = (char) sa[sp++];
- }
-
- while (sp < sl) {
- int b1 = sa[sp++];
- if (b1 >= 0) {
- // 1 byte, 7 bits: 0xxxxxxx
- da[dp++] = (char) b1;
- } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
- // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
- if (sp < sl) {
- int b2 = sa[sp++];
- if ((b2 & 0xc0) != 0x80) { // isNotContinuation(b2)
- return -1;
- } else {
- da[dp++] = (char) (((b1 << 6) ^ b2) ^ (((byte) 0xC0 << 6) ^ ((byte) 0x80)));
- }
- continue;
- }
- return -1;
- } else if ((b1 >> 4) == -2) {
- // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
- if (sp + 1 < sl) {
- int b2 = sa[sp++];
- int b3 = sa[sp++];
- if ((b1 == (byte) 0xe0 && (b2 & 0xe0) == 0x80)
- || (b2 & 0xc0) != 0x80
- || (b3 & 0xc0) != 0x80) { // isMalformed3(b1, b2, b3)
- return -1;
- } else {
- char c =
- (char)
- ((b1 << 12)
- ^ (b2 << 6)
- ^ (b3
- ^ (((byte) 0xE0 << 12)
- ^ ((byte) 0x80 << 6)
- ^ ((byte) 0x80))));
- if (Character.isSurrogate(c)) {
- return -1;
- } else {
- da[dp++] = c;
- }
- }
- continue;
- }
- return -1;
- } else if ((b1 >> 3) == -2) {
- // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- if (sp + 2 < sl) {
- int b2 = sa[sp++];
- int b3 = sa[sp++];
- int b4 = sa[sp++];
- int uc =
- ((b1 << 18)
- ^ (b2 << 12)
- ^ (b3 << 6)
- ^ (b4
- ^ (((byte) 0xF0 << 18)
- ^ ((byte) 0x80 << 12)
- ^ ((byte) 0x80 << 6)
- ^ ((byte) 0x80))));
- // isMalformed4 and shortest form check
- if (((b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || (b4 & 0xc0) != 0x80)
- || !Character.isSupplementaryCodePoint(uc)) {
- return -1;
- } else {
- da[dp++] = Character.highSurrogate(uc);
- da[dp++] = Character.lowSurrogate(uc);
- }
- continue;
- }
- return -1;
- } else {
- return -1;
- }
- }
- return dp;
- }
-
- private static String defaultDecodeUTF8(byte[] bytes, int offset, int len) {
- return new String(bytes, offset, len, StandardCharsets.UTF_8);
- }
- }
-
- private static IllegalArgumentException newCanNotConvertException(FieldDescriptor field, DataType fieldDataType){
- return new IllegalArgumentException(String.format("proto field:%s(%s) can not convert to type:%s", field.getName(), field.getType(), fieldDataType.simpleString()));
- }
-
- @FunctionalInterface
- public interface ValueConverter {
- Object convert(CodedInputStream input, boolean packed) throws Exception;
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors;
+import com.geedgenetworks.core.types.*;
+import com.geedgenetworks.core.types.StructType.StructField;
+import com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor;
+import com.geedgenetworks.shaded.com.google.protobuf.WireFormat;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flink.util.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class SchemaConverters {
+ static final Logger LOG = LoggerFactory.getLogger(SchemaConverters.class);
+ public static StructType toStructType(Descriptor descriptor) {
+ StructField[] fields = descriptor.getFields().stream().map(f -> structFieldFor(f)).toArray(StructField[]::new);
+ return new StructType(fields);
+ }
+
+ private static StructField structFieldFor(FieldDescriptor fd) {
+ WireFormat.FieldType type = fd.getLiteType();
+ DataType dataType;
+ switch (type) {
+ case DOUBLE:
+ dataType = Types.DOUBLE;
+ break;
+ case FLOAT:
+ dataType = Types.FLOAT;
+ break;
+ case INT64:
+ case UINT64:
+ case FIXED64:
+ case SINT64:
+ case SFIXED64:
+ dataType = Types.BIGINT;
+ break;
+ case INT32:
+ case UINT32:
+ case FIXED32:
+ case SINT32:
+ case SFIXED32:
+ dataType = Types.INT;
+ break;
+ case BOOL:
+ dataType = Types.BOOLEAN;
+ break;
+ case STRING:
+ dataType = Types.STRING;
+ break;
+ case BYTES:
+ dataType = Types.BINARY;
+ break;
+ case ENUM:
+ dataType = Types.INT;
+ break;
+ case MESSAGE:
+ if (fd.isRepeated() && fd.getMessageType().getOptions().hasMapEntry()) {
+ throw new IllegalArgumentException(String.format("not supported type:%s(%s)", type, fd.getName()));
+ } else {
+ StructField[] fields = fd.getMessageType().getFields().stream().map(f -> structFieldFor(f)).toArray(StructField[]::new);
+ dataType = new StructType(fields);
+ }
+ break;
+ default:
+ throw new IllegalArgumentException(String.format("not supported type:%s(%s)", type, fd.getName()));
+ }
+ if (fd.isRepeated()) {
+ return new StructField(fd.getName(), new ArrayType(dataType));
+ } else {
+ return new StructField(fd.getName(), dataType);
+ }
+ }
+
+ // 校验dataType和descriptor是否匹配,dataType中定义的属性必须全部在descriptor定义,每个字段的类型必须匹配(相同或者能够转换)
+ public static void checkMatch(Descriptor descriptor, StructType dataType) throws Exception {
+ checkMatch(descriptor, dataType, null);
+ }
+
+ private static void checkMatch(Descriptor descriptor, StructType dataType, String prefix) throws Exception {
+ List<FieldDescriptor> fieldDescriptors = descriptor.getFields();
+ Map<String, FieldDescriptor> fdMap = fieldDescriptors.stream().collect(Collectors.toMap(x -> x.getName(), x -> x));
+ StructField[] fields = dataType.fields;
+
+ for (int i = 0; i < fields.length; i++) {
+ StructField field = fields[i];
+ FieldDescriptor fd = fdMap.get(field.name);
+ if(fd == null){
+ throw new IllegalArgumentException(String.format("%s ' field:%s not found in proto descriptor", StringUtils.isBlank(prefix)? "root": prefix, field));
+ }
+ WireFormat.FieldType type = fd.getLiteType();
+ DataType fieldDataType;
+ if(fd.isRepeated()){
+ if(!(field.dataType instanceof ArrayType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ fieldDataType = ((ArrayType)field.dataType).elementType;
+ }else{
+ fieldDataType = field.dataType;
+ }
+ switch (type) {
+ case DOUBLE:
+ case FLOAT:
+ if(!(fieldDataType instanceof DoubleType || fieldDataType instanceof FloatType
+ || fieldDataType instanceof IntegerType || fieldDataType instanceof LongType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case INT64:
+ case UINT64:
+ case FIXED64:
+ case SINT64:
+ case SFIXED64:
+ if(!(fieldDataType instanceof IntegerType || fieldDataType instanceof LongType
+ || fieldDataType instanceof FloatType || fieldDataType instanceof DoubleType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case INT32:
+ case UINT32:
+ case FIXED32:
+ case SINT32:
+ case SFIXED32:
+ if(!(fieldDataType instanceof IntegerType || fieldDataType instanceof LongType
+ || fieldDataType instanceof FloatType || fieldDataType instanceof DoubleType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case BOOL:
+ if(!(fieldDataType instanceof BooleanType || fieldDataType instanceof IntegerType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case STRING:
+ if(!(fieldDataType instanceof StringType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case BYTES:
+ if(!(fieldDataType instanceof BinaryType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case ENUM:
+ if(!(fieldDataType instanceof IntegerType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ break;
+ case MESSAGE:
+ if(!(fieldDataType instanceof StructType)){
+ throw newNotMatchException(field, fd, prefix);
+ }
+ checkMatch(fd.getMessageType(), (StructType) fieldDataType, StringUtils.isBlank(prefix)? field.name: prefix + "." + field.name);
+ }
+ }
+ }
+
+ private static IllegalArgumentException newNotMatchException(StructField field, FieldDescriptor fd, String prefix){
+ return new IllegalArgumentException(String.format("%s ' field:%s not match with proto field descriptor:%s(%s)", StringUtils.isBlank(prefix)? "root": prefix, field, fd, fd.getType()));
+ }
+
+ public static class MessageConverter {
+ private static final int MAX_CHARS_LENGTH = 1024 * 4;
+ FieldDesc[] fieldDescArray; // Message类型对应FieldDesc, 下标为field number
+ int initialCapacity = 0;
+ final boolean emitDefaultValues;
+ final DefaultValue[] defaultValues;
+ private final char[] tmpDecodeChars = new char[MAX_CHARS_LENGTH]; // 同一个Message的转换是在一个线程内,fieldDesc共用一个临时chars
+
+ public MessageConverter(Descriptor descriptor, StructType dataType, boolean emitDefaultValues) {
+ ProtobufUtils.checkSupportParseDescriptor(descriptor);
+ List<FieldDescriptor> fields = descriptor.getFields();
+ int maxNumber = fields.stream().mapToInt(f -> f.getNumber()).max().getAsInt();
+ Preconditions.checkArgument(maxNumber < 10000, maxNumber);
+ fieldDescArray = new FieldDesc[maxNumber + 1];
+
+ this.emitDefaultValues = emitDefaultValues;
+ if(this.emitDefaultValues){
+ defaultValues = new DefaultValue[dataType.fields.length];
+ }else{
+ defaultValues = null;
+ }
+
+ for (FieldDescriptor field : fields) {
+ // Optional<StructField> structFieldOptional = Arrays.stream(dataType.fields).filter(f -> f.name.equals(field.getName())).findFirst();
+ // if(structFieldOptional.isPresent()){
+ int position = -1;
+ for (int i = 0; i < dataType.fields.length; i++) {
+ if(dataType.fields[i].name.equals(field.getName())){
+ position = i;
+ break;
+ }
+ }
+ if(position >= 0){
+ fieldDescArray[field.getNumber()] = new FieldDesc(field, dataType.fields[position].dataType, position, emitDefaultValues, tmpDecodeChars);
+ if(this.emitDefaultValues){
+ defaultValues[position] = new DefaultValue(dataType.fields[position].name, getDefaultValue(field, dataType.fields[position].dataType));
+ }
+ }
+ }
+ if(dataType.fields.length / 3 > 16){
+ initialCapacity = (dataType.fields.length / 3) ;
+ }
+ if(this.emitDefaultValues){
+ LOG.warn("enable emitDefaultValues will seriously affect performance !!!");
+ for (int i = 0; i < defaultValues.length; i++) {
+ if (defaultValues[i] == null) {
+ throw new IllegalArgumentException(String.format("%s and %s not match", dataType, descriptor));
+ }
+ }
+ }
+ }
+
+ public Map<String, Object> converter(byte[] bytes) throws Exception {
+ CodedInputStream input = CodedInputStream.newInstance(bytes);
+ return emitDefaultValues ? converterEmitDefaultValues(input): converterNoEmitDefaultValues(input);
+ }
+
+ public Map<String, Object> converter(CodedInputStream input) throws Exception {
+ return emitDefaultValues ? converterEmitDefaultValues(input): converterNoEmitDefaultValues(input);
+ }
+
+ private Map<String, Object> converterNoEmitDefaultValues(CodedInputStream input) throws Exception {
+ Map<String, Object> data = initialCapacity == 0? new HashMap<>(): new HashMap<>(initialCapacity);
+
+ while (true) {
+ int tag = input.readTag();
+ if (tag == 0) {
+ break;
+ }
+
+ final int wireType = WireFormat.getTagWireType(tag);
+ final int fieldNumber = WireFormat.getTagFieldNumber(tag);
+
+ FieldDesc fieldDesc = null;
+ if (fieldNumber < fieldDescArray.length) {
+ fieldDesc = fieldDescArray[fieldNumber];
+ }
+
+ boolean unknown = false;
+ boolean packed = false;
+ if (fieldDesc == null) {
+ unknown = true; // Unknown field.
+ } else if (wireType == fieldDesc.field.getLiteType().getWireType()) {
+ packed = false;
+ } else if (fieldDesc.field.isPackable() && wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
+ packed = true;
+ } else {
+ unknown = true; // Unknown wire type.
+ }
+
+ if (unknown) { // Unknown field or wrong wire type. Skip.
+ input.skipField(tag);
+ continue;
+ }
+
+ String name = fieldDesc.name;
+ if (packed) {
+ final int length = input.readRawVarint32();
+ final int limit = input.pushLimit(length);
+ List<Object> array = (List<Object>) fieldDesc.valueConverter.convert(input, true);
+ input.popLimit(limit);
+ List<Object> oldArray = (List<Object>)data.get(name);
+ if(oldArray == null){
+ data.put(name, array);
+ }else{
+ oldArray.addAll(array);
+ }
+ } else {
+ final Object value = fieldDesc.valueConverter.convert(input, false);
+ if(!fieldDesc.field.isRepeated()){
+ data.put(name, value);
+ }else{
+ List<Object> array = (List<Object>)data.get(name);
+ if(array == null){
+ array = new ArrayList<>();
+ data.put(name, array);
+ }
+ array.add(value);
+ }
+ }
+
+ }
+
+ return data;
+ }
+ private Map<String, Object> converterEmitDefaultValues(CodedInputStream input) throws Exception {
+ Map<String, Object> data = initialCapacity == 0? new HashMap<>(): new HashMap<>(initialCapacity);
+
+ // 比converterNoEmitDefaultValues多的代码
+ for (int i = 0; i < defaultValues.length; i++) {
+ defaultValues[i].hasValue = false;
+ }
+
+ while (true) {
+ int tag = input.readTag();
+ if (tag == 0) {
+ break;
+ }
+
+ final int wireType = WireFormat.getTagWireType(tag);
+ final int fieldNumber = WireFormat.getTagFieldNumber(tag);
+
+ FieldDesc fieldDesc = null;
+ if (fieldNumber < fieldDescArray.length) {
+ fieldDesc = fieldDescArray[fieldNumber];
+ }
+
+ boolean unknown = false;
+ boolean packed = false;
+ if (fieldDesc == null) {
+ unknown = true; // Unknown field.
+ } else if (wireType == fieldDesc.field.getLiteType().getWireType()) {
+ packed = false;
+ } else if (fieldDesc.field.isPackable() && wireType == WireFormat.WIRETYPE_LENGTH_DELIMITED) {
+ packed = true;
+ } else {
+ unknown = true; // Unknown wire type.
+ }
+
+ if (unknown) { // Unknown field or wrong wire type. Skip.
+ input.skipField(tag);
+ continue;
+ }
+
+ // 比converterNoEmitDefaultValues多的代码
+ defaultValues[fieldDesc.fieldPosition].hasValue = true;
+
+ String name = fieldDesc.name;
+ if (packed) {
+ final int length = input.readRawVarint32();
+ final int limit = input.pushLimit(length);
+ List<Object> array = (List<Object>) fieldDesc.valueConverter.convert(input, true);
+ input.popLimit(limit);
+ List<Object> oldArray = (List<Object>)data.get(name);
+ if(oldArray == null){
+ data.put(name, array);
+ }else{
+ oldArray.addAll(array);
+ }
+ } else {
+ final Object value = fieldDesc.valueConverter.convert(input, false);
+ if(!fieldDesc.field.isRepeated()){
+ data.put(name, value);
+ }else{
+ List<Object> array = (List<Object>)data.get(name);
+ if(array == null){
+ array = new ArrayList<>();
+ data.put(name, array);
+ }
+ array.add(value);
+ }
+ }
+
+ }
+
+ // 比converterNoEmitDefaultValues多的代码
+ DefaultValue defaultValue;
+ for (int i = 0; i < defaultValues.length; i++) {
+ defaultValue = defaultValues[i];
+ if(!defaultValue.hasValue && defaultValue.defaultValue != null){
+ data.put(defaultValue.name, defaultValue.defaultValue);
+ }
+ }
+
+ return data;
+ }
+
+ private Object getDefaultValue(FieldDescriptor field, DataType fieldDataType){
+ if(field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE){
+ return null;
+ }
+ if(field.isRepeated()){
+ return null;
+ }
+ if(field.hasOptionalKeyword()){
+ return null;
+ }
+
+ switch (field.getType()) {
+ case DOUBLE:
+ case FLOAT:
+ case INT64:
+ case UINT64:
+ case FIXED64:
+ case SFIXED64:
+ case SINT64:
+ case INT32:
+ case UINT32:
+ case FIXED32:
+ case SFIXED32:
+ case SINT32:
+ Number number = 0L;
+ if (fieldDataType instanceof DoubleType) {
+ return number.doubleValue();
+ } else if (fieldDataType instanceof FloatType) {
+ return number.floatValue();
+ } else if (fieldDataType instanceof IntegerType) {
+ return number.intValue();
+ } else if (fieldDataType instanceof LongType) {
+ return number.longValue();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case BOOL:
+ if (fieldDataType instanceof BooleanType) {
+ return false;
+ } else if (fieldDataType instanceof IntegerType) {
+ return 0;
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case BYTES:
+ if (fieldDataType instanceof BinaryType) {
+ return new byte[0];
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case STRING:
+ if (fieldDataType instanceof StringType) {
+ return "";
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case ENUM:
+ if (fieldDataType instanceof IntegerType) {
+ return ((Descriptors.EnumValueDescriptor) field.getDefaultValue()).getNumber();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ default:
+ throw new IllegalArgumentException(String.format("not supported proto type:%s(%s)", field.getType(), field.getName()));
+ }
+ }
+ }
+
+ public static class DefaultValue{
+ boolean hasValue;
+ final String name;
+
+ final Object defaultValue;
+
+ public DefaultValue(String name, Object defaultValue) {
+ this.name = name;
+ this.defaultValue = defaultValue;
+ }
+ }
+
+ public static class FieldDesc {
+ final FieldDescriptor field;
+ final String name;
+ final DataType fieldDataType; // field对应DataType,array类型存对应元素的类型
+ final int fieldPosition; // field位置
+
+ final ValueConverter valueConverter;
+ private final char[] tmpDecodeChars;
+
+ public FieldDesc(FieldDescriptor field, DataType dataType, int fieldPosition, boolean emitDefaultValues, char[] tmpDecodeChars) {
+ this.field = field;
+ this.name = field.getName();
+ if (dataType instanceof ArrayType) {
+ this.fieldDataType = ((ArrayType) dataType).elementType;
+ } else {
+ this.fieldDataType = dataType;
+ }
+ this.fieldPosition = fieldPosition;
+ this.tmpDecodeChars = tmpDecodeChars;
+ valueConverter = makeConverter(emitDefaultValues);
+ }
+
+ private ValueConverter makeConverter(boolean emitDefaultValues) {
+ switch (field.getType()) {
+ case ENUM:
+ if(!(fieldDataType instanceof IntegerType)){
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ return (input, packed) -> {
+ if (packed) {
+ List<Object> array = new ArrayList<>();
+ while (input.getBytesUntilLimit() > 0) {
+ array.add(input.readEnum());
+ }
+ return array;
+ } else {
+ return input.readEnum();
+ }
+ };
+ case MESSAGE:
+ final Descriptor descriptor = field.getMessageType();
+ final MessageConverter messageConverter = new MessageConverter(descriptor, (StructType) fieldDataType, emitDefaultValues);
+ return (input, packed) -> {
+ final int length = input.readRawVarint32();
+ final int oldLimit = input.pushLimit(length);
+ Object message = messageConverter.converter(input);
+ input.checkLastTagWas(0);
+ if (input.getBytesUntilLimit() != 0) {
+ throw new RuntimeException("parse");
+ }
+ input.popLimit(oldLimit);
+ return message;
+ };
+ default:
+ ValueConverter fieldConverter = makePrimitiveFieldConverter();
+ return (input, packed) -> {
+ if (packed) {
+ List<Object> array = new ArrayList<>();
+ while (input.getBytesUntilLimit() > 0) {
+ array.add(fieldConverter.convert(input, false));
+ }
+ return array;
+ } else {
+ return fieldConverter.convert(input, false);
+ }
+ };
+ }
+ }
+
+ private ValueConverter makePrimitiveFieldConverter() {
+ switch (field.getType()) {
+ case DOUBLE:
+ if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> input.readDouble();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readDouble();
+ } else if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readDouble();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readDouble();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case FLOAT:
+ if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readFloat();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> input.readFloat();
+ } else if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readFloat();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readFloat();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case INT64:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readInt64();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> input.readInt64();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readInt64();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readInt64();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case UINT64:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readUInt64();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> input.readUInt64();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readUInt64();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readUInt64();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case FIXED64:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readFixed64();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> input.readFixed64();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readFixed64();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readFixed64();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case SFIXED64:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readSFixed64();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> input.readSFixed64();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readSFixed64();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readSFixed64();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case SINT64:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> (int) input.readSInt64();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> input.readSInt64();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readSInt64();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readSInt64();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case INT32:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readInt32();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readInt32();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readInt32();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readInt32();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case UINT32:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readUInt32();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readUInt32();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readUInt32();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readUInt32();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case FIXED32:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readFixed32();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readFixed32();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readFixed32();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readFixed32();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case SFIXED32:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readSFixed32();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readSFixed32();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readSFixed32();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readSFixed32();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case SINT32:
+ if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readSInt32();
+ } else if (fieldDataType instanceof LongType) {
+ return (input, packed) -> (long) input.readSInt32();
+ } else if (fieldDataType instanceof FloatType) {
+ return (input, packed) -> (float) input.readSInt32();
+ } else if (fieldDataType instanceof DoubleType) {
+ return (input, packed) -> (double) input.readSInt32();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case BOOL:
+ if (fieldDataType instanceof BooleanType) {
+ return (input, packed) -> input.readBool();
+ } else if (fieldDataType instanceof IntegerType) {
+ return (input, packed) -> input.readBool() ? 1 : 0;
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case BYTES:
+ if (fieldDataType instanceof BinaryType) {
+ return (input, packed) -> input.readByteArray();
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ case STRING:
+ if (fieldDataType instanceof StringType) {
+ return (input, packed) -> {
+ //return input.readString();
+ byte[] bytes = input.readByteArray();
+ return decodeUTF8(bytes, 0, bytes.length);
+ };
+ } else {
+ throw newCanNotConvertException(field, fieldDataType);
+ }
+ default:
+ throw new IllegalArgumentException(String.format("not supported proto type:%s(%s)", field.getType(), field.getName()));
+ }
+ }
+
+ private String decodeUTF8(byte[] input, int offset, int byteLen) {
+ char[] chars = MessageConverter.MAX_CHARS_LENGTH < byteLen? new char[byteLen]: tmpDecodeChars;
+ int len = decodeUTF8Strict(input, offset, byteLen, chars);
+ if (len < 0) {
+ return defaultDecodeUTF8(input, offset, byteLen);
+ }
+ return new String(chars, 0, len);
+ }
+
+ private static int decodeUTF8Strict(byte[] sa, int sp, int len, char[] da) {
+ final int sl = sp + len;
+ int dp = 0;
+ int dlASCII = Math.min(len, da.length);
+
+ // ASCII only optimized loop
+ while (dp < dlASCII && sa[sp] >= 0) {
+ da[dp++] = (char) sa[sp++];
+ }
+
+ while (sp < sl) {
+ int b1 = sa[sp++];
+ if (b1 >= 0) {
+ // 1 byte, 7 bits: 0xxxxxxx
+ da[dp++] = (char) b1;
+ } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
+ // 2 bytes, 11 bits: 110xxxxx 10xxxxxx
+ if (sp < sl) {
+ int b2 = sa[sp++];
+ if ((b2 & 0xc0) != 0x80) { // isNotContinuation(b2)
+ return -1;
+ } else {
+ da[dp++] = (char) (((b1 << 6) ^ b2) ^ (((byte) 0xC0 << 6) ^ ((byte) 0x80)));
+ }
+ continue;
+ }
+ return -1;
+ } else if ((b1 >> 4) == -2) {
+ // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
+ if (sp + 1 < sl) {
+ int b2 = sa[sp++];
+ int b3 = sa[sp++];
+ if ((b1 == (byte) 0xe0 && (b2 & 0xe0) == 0x80)
+ || (b2 & 0xc0) != 0x80
+ || (b3 & 0xc0) != 0x80) { // isMalformed3(b1, b2, b3)
+ return -1;
+ } else {
+ char c =
+ (char)
+ ((b1 << 12)
+ ^ (b2 << 6)
+ ^ (b3
+ ^ (((byte) 0xE0 << 12)
+ ^ ((byte) 0x80 << 6)
+ ^ ((byte) 0x80))));
+ if (Character.isSurrogate(c)) {
+ return -1;
+ } else {
+ da[dp++] = c;
+ }
+ }
+ continue;
+ }
+ return -1;
+ } else if ((b1 >> 3) == -2) {
+ // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ if (sp + 2 < sl) {
+ int b2 = sa[sp++];
+ int b3 = sa[sp++];
+ int b4 = sa[sp++];
+ int uc =
+ ((b1 << 18)
+ ^ (b2 << 12)
+ ^ (b3 << 6)
+ ^ (b4
+ ^ (((byte) 0xF0 << 18)
+ ^ ((byte) 0x80 << 12)
+ ^ ((byte) 0x80 << 6)
+ ^ ((byte) 0x80))));
+ // isMalformed4 and shortest form check
+ if (((b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || (b4 & 0xc0) != 0x80)
+ || !Character.isSupplementaryCodePoint(uc)) {
+ return -1;
+ } else {
+ da[dp++] = Character.highSurrogate(uc);
+ da[dp++] = Character.lowSurrogate(uc);
+ }
+ continue;
+ }
+ return -1;
+ } else {
+ return -1;
+ }
+ }
+ return dp;
+ }
+
+ private static String defaultDecodeUTF8(byte[] bytes, int offset, int len) {
+ return new String(bytes, offset, len, StandardCharsets.UTF_8);
+ }
+ }
+
+ private static IllegalArgumentException newCanNotConvertException(FieldDescriptor field, DataType fieldDataType){
+ return new IllegalArgumentException(String.format("proto field:%s(%s) can not convert to type:%s", field.getName(), field.getType(), fieldDataType.simpleString()));
+ }
+
+ @FunctionalInterface
+ public interface ValueConverter {
+ Object convert(CodedInputStream input, boolean packed) throws Exception;
+ }
+}
diff --git a/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/Proto3TypesProtos.java b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/Proto3TypesProtos.java
index 742d171..013b168 100644
--- a/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/Proto3TypesProtos.java
+++ b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/Proto3TypesProtos.java
@@ -1,3803 +1,3803 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: proto3_types.proto
-
-package com.geedgenetworks.formats.protobuf;
-
-public final class Proto3TypesProtos {
- private Proto3TypesProtos() {}
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistryLite registry) {
- }
-
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistry registry) {
- registerAllExtensions(
- (com.google.protobuf.ExtensionRegistryLite) registry);
- }
- public interface StructMessageOrBuilder extends
- // @@protoc_insertion_point(interface_extends:StructMessage)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>int64 id = 1;</code>
- * @return The id.
- */
- long getId();
-
- /**
- * <code>string name = 2;</code>
- * @return The name.
- */
- java.lang.String getName();
- /**
- * <code>string name = 2;</code>
- * @return The bytes for name.
- */
- com.google.protobuf.ByteString
- getNameBytes();
-
- /**
- * <code>int32 age = 3;</code>
- * @return The age.
- */
- int getAge();
-
- /**
- * <code>double score = 4;</code>
- * @return The score.
- */
- double getScore();
-
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return Whether the optionalId field is set.
- */
- boolean hasOptionalId();
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return The optionalId.
- */
- long getOptionalId();
-
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return Whether the optionalAge field is set.
- */
- boolean hasOptionalAge();
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return The optionalAge.
- */
- int getOptionalAge();
- }
- /**
- * Protobuf type {@code StructMessage}
- */
- public static final class StructMessage extends
- com.google.protobuf.GeneratedMessageV3 implements
- // @@protoc_insertion_point(message_implements:StructMessage)
- StructMessageOrBuilder {
- private static final long serialVersionUID = 0L;
- // Use StructMessage.newBuilder() to construct.
- private StructMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
- super(builder);
- }
- private StructMessage() {
- name_ = "";
- }
-
- @java.lang.Override
- @SuppressWarnings({"unused"})
- protected java.lang.Object newInstance(
- UnusedPrivateParameter unused) {
- return new StructMessage();
- }
-
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
- }
-
- @java.lang.Override
- protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder.class);
- }
-
- private int bitField0_;
- public static final int ID_FIELD_NUMBER = 1;
- private long id_ = 0L;
- /**
- * <code>int64 id = 1;</code>
- * @return The id.
- */
- @java.lang.Override
- public long getId() {
- return id_;
- }
-
- public static final int NAME_FIELD_NUMBER = 2;
- @SuppressWarnings("serial")
- private volatile java.lang.Object name_ = "";
- /**
- * <code>string name = 2;</code>
- * @return The name.
- */
- @java.lang.Override
- public java.lang.String getName() {
- java.lang.Object ref = name_;
- 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();
- name_ = s;
- return s;
- }
- }
- /**
- * <code>string name = 2;</code>
- * @return The bytes for name.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString
- getNameBytes() {
- java.lang.Object ref = name_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int AGE_FIELD_NUMBER = 3;
- private int age_ = 0;
- /**
- * <code>int32 age = 3;</code>
- * @return The age.
- */
- @java.lang.Override
- public int getAge() {
- return age_;
- }
-
- public static final int SCORE_FIELD_NUMBER = 4;
- private double score_ = 0D;
- /**
- * <code>double score = 4;</code>
- * @return The score.
- */
- @java.lang.Override
- public double getScore() {
- return score_;
- }
-
- public static final int OPTIONAL_ID_FIELD_NUMBER = 5;
- private long optionalId_ = 0L;
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return Whether the optionalId field is set.
- */
- @java.lang.Override
- public boolean hasOptionalId() {
- return ((bitField0_ & 0x00000001) != 0);
- }
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return The optionalId.
- */
- @java.lang.Override
- public long getOptionalId() {
- return optionalId_;
- }
-
- public static final int OPTIONAL_AGE_FIELD_NUMBER = 6;
- private int optionalAge_ = 0;
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return Whether the optionalAge field is set.
- */
- @java.lang.Override
- public boolean hasOptionalAge() {
- return ((bitField0_ & 0x00000002) != 0);
- }
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return The optionalAge.
- */
- @java.lang.Override
- public int getOptionalAge() {
- return optionalAge_;
- }
-
- private byte memoizedIsInitialized = -1;
- @java.lang.Override
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- @java.lang.Override
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- if (id_ != 0L) {
- output.writeInt64(1, id_);
- }
- if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_);
- }
- if (age_ != 0) {
- output.writeInt32(3, age_);
- }
- if (java.lang.Double.doubleToRawLongBits(score_) != 0) {
- output.writeDouble(4, score_);
- }
- if (((bitField0_ & 0x00000001) != 0)) {
- output.writeInt64(5, optionalId_);
- }
- if (((bitField0_ & 0x00000002) != 0)) {
- output.writeInt32(6, optionalAge_);
- }
- getUnknownFields().writeTo(output);
- }
-
- @java.lang.Override
- public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) return size;
-
- size = 0;
- if (id_ != 0L) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(1, id_);
- }
- if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
- size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_);
- }
- if (age_ != 0) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(3, age_);
- }
- if (java.lang.Double.doubleToRawLongBits(score_) != 0) {
- size += com.google.protobuf.CodedOutputStream
- .computeDoubleSize(4, score_);
- }
- if (((bitField0_ & 0x00000001) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(5, optionalId_);
- }
- if (((bitField0_ & 0x00000002) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(6, optionalAge_);
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSize = size;
- return size;
- }
-
- @java.lang.Override
- public boolean equals(final java.lang.Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage)) {
- return super.equals(obj);
- }
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage other = (com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage) obj;
-
- if (getId()
- != other.getId()) return false;
- if (!getName()
- .equals(other.getName())) return false;
- if (getAge()
- != other.getAge()) return false;
- if (java.lang.Double.doubleToLongBits(getScore())
- != java.lang.Double.doubleToLongBits(
- other.getScore())) return false;
- if (hasOptionalId() != other.hasOptionalId()) return false;
- if (hasOptionalId()) {
- if (getOptionalId()
- != other.getOptionalId()) return false;
- }
- if (hasOptionalAge() != other.hasOptionalAge()) return false;
- if (hasOptionalAge()) {
- if (getOptionalAge()
- != other.getOptionalAge()) return false;
- }
- if (!getUnknownFields().equals(other.getUnknownFields())) return false;
- return true;
- }
-
- @java.lang.Override
- public int hashCode() {
- if (memoizedHashCode != 0) {
- return memoizedHashCode;
- }
- int hash = 41;
- hash = (19 * hash) + getDescriptor().hashCode();
- hash = (37 * hash) + ID_FIELD_NUMBER;
- hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
- getId());
- hash = (37 * hash) + NAME_FIELD_NUMBER;
- hash = (53 * hash) + getName().hashCode();
- hash = (37 * hash) + AGE_FIELD_NUMBER;
- hash = (53 * hash) + getAge();
- hash = (37 * hash) + SCORE_FIELD_NUMBER;
- hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
- java.lang.Double.doubleToLongBits(getScore()));
- if (hasOptionalId()) {
- hash = (37 * hash) + OPTIONAL_ID_FIELD_NUMBER;
- hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
- getOptionalId());
- }
- if (hasOptionalAge()) {
- hash = (37 * hash) + OPTIONAL_AGE_FIELD_NUMBER;
- hash = (53 * hash) + getOptionalAge();
- }
- hash = (29 * hash) + getUnknownFields().hashCode();
- memoizedHashCode = hash;
- return hash;
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- java.nio.ByteBuffer data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- java.nio.ByteBuffer data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input);
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- @java.lang.Override
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder() {
- return DEFAULT_INSTANCE.toBuilder();
- }
- public static Builder newBuilder(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage prototype) {
- return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
- }
- @java.lang.Override
- public Builder toBuilder() {
- return this == DEFAULT_INSTANCE
- ? new Builder() : new Builder().mergeFrom(this);
- }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code StructMessage}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:StructMessage)
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
- }
-
- @java.lang.Override
- protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder.class);
- }
-
- // Construct using com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.newBuilder()
- private Builder() {
-
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- super(parent);
-
- }
- @java.lang.Override
- public Builder clear() {
- super.clear();
- bitField0_ = 0;
- id_ = 0L;
- name_ = "";
- age_ = 0;
- score_ = 0D;
- optionalId_ = 0L;
- optionalAge_ = 0;
- return this;
- }
-
- @java.lang.Override
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstanceForType() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance();
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage build() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage buildPartial() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage(this);
- if (bitField0_ != 0) { buildPartial0(result); }
- onBuilt();
- return result;
- }
-
- private void buildPartial0(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result) {
- int from_bitField0_ = bitField0_;
- if (((from_bitField0_ & 0x00000001) != 0)) {
- result.id_ = id_;
- }
- if (((from_bitField0_ & 0x00000002) != 0)) {
- result.name_ = name_;
- }
- if (((from_bitField0_ & 0x00000004) != 0)) {
- result.age_ = age_;
- }
- if (((from_bitField0_ & 0x00000008) != 0)) {
- result.score_ = score_;
- }
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000010) != 0)) {
- result.optionalId_ = optionalId_;
- to_bitField0_ |= 0x00000001;
- }
- if (((from_bitField0_ & 0x00000020) != 0)) {
- result.optionalAge_ = optionalAge_;
- to_bitField0_ |= 0x00000002;
- }
- result.bitField0_ |= to_bitField0_;
- }
-
- @java.lang.Override
- public Builder clone() {
- return super.clone();
- }
- @java.lang.Override
- public Builder setField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- java.lang.Object value) {
- return super.setField(field, value);
- }
- @java.lang.Override
- public Builder clearField(
- com.google.protobuf.Descriptors.FieldDescriptor field) {
- return super.clearField(field);
- }
- @java.lang.Override
- public Builder clearOneof(
- com.google.protobuf.Descriptors.OneofDescriptor oneof) {
- return super.clearOneof(oneof);
- }
- @java.lang.Override
- public Builder setRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- int index, java.lang.Object value) {
- return super.setRepeatedField(field, index, value);
- }
- @java.lang.Override
- public Builder addRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- java.lang.Object value) {
- return super.addRepeatedField(field, value);
- }
- @java.lang.Override
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage) {
- return mergeFrom((com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage other) {
- if (other == com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) return this;
- if (other.getId() != 0L) {
- setId(other.getId());
- }
- if (!other.getName().isEmpty()) {
- name_ = other.name_;
- bitField0_ |= 0x00000002;
- onChanged();
- }
- if (other.getAge() != 0) {
- setAge(other.getAge());
- }
- if (other.getScore() != 0D) {
- setScore(other.getScore());
- }
- if (other.hasOptionalId()) {
- setOptionalId(other.getOptionalId());
- }
- if (other.hasOptionalAge()) {
- setOptionalAge(other.getOptionalAge());
- }
- this.mergeUnknownFields(other.getUnknownFields());
- onChanged();
- return this;
- }
-
- @java.lang.Override
- public final boolean isInitialized() {
- return true;
- }
-
- @java.lang.Override
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- if (extensionRegistry == null) {
- throw new java.lang.NullPointerException();
- }
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- case 8: {
- id_ = input.readInt64();
- bitField0_ |= 0x00000001;
- break;
- } // case 8
- case 18: {
- name_ = input.readStringRequireUtf8();
- bitField0_ |= 0x00000002;
- break;
- } // case 18
- case 24: {
- age_ = input.readInt32();
- bitField0_ |= 0x00000004;
- break;
- } // case 24
- case 33: {
- score_ = input.readDouble();
- bitField0_ |= 0x00000008;
- break;
- } // case 33
- case 40: {
- optionalId_ = input.readInt64();
- bitField0_ |= 0x00000010;
- break;
- } // case 40
- case 48: {
- optionalAge_ = input.readInt32();
- bitField0_ |= 0x00000020;
- break;
- } // case 48
- default: {
- if (!super.parseUnknownField(input, extensionRegistry, tag)) {
- done = true; // was an endgroup tag
- }
- break;
- } // default:
- } // switch (tag)
- } // while (!done)
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.unwrapIOException();
- } finally {
- onChanged();
- } // finally
- return this;
- }
- private int bitField0_;
-
- private long id_ ;
- /**
- * <code>int64 id = 1;</code>
- * @return The id.
- */
- @java.lang.Override
- public long getId() {
- return id_;
- }
- /**
- * <code>int64 id = 1;</code>
- * @param value The id to set.
- * @return This builder for chaining.
- */
- public Builder setId(long value) {
-
- id_ = value;
- bitField0_ |= 0x00000001;
- onChanged();
- return this;
- }
- /**
- * <code>int64 id = 1;</code>
- * @return This builder for chaining.
- */
- public Builder clearId() {
- bitField0_ = (bitField0_ & ~0x00000001);
- id_ = 0L;
- onChanged();
- return this;
- }
-
- private java.lang.Object name_ = "";
- /**
- * <code>string name = 2;</code>
- * @return The name.
- */
- public java.lang.String getName() {
- java.lang.Object ref = name_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- name_ = s;
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>string name = 2;</code>
- * @return The bytes for name.
- */
- public com.google.protobuf.ByteString
- getNameBytes() {
- java.lang.Object ref = name_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>string name = 2;</code>
- * @param value The name to set.
- * @return This builder for chaining.
- */
- public Builder setName(
- java.lang.String value) {
- if (value == null) { throw new NullPointerException(); }
- name_ = value;
- bitField0_ |= 0x00000002;
- onChanged();
- return this;
- }
- /**
- * <code>string name = 2;</code>
- * @return This builder for chaining.
- */
- public Builder clearName() {
- name_ = getDefaultInstance().getName();
- bitField0_ = (bitField0_ & ~0x00000002);
- onChanged();
- return this;
- }
- /**
- * <code>string name = 2;</code>
- * @param value The bytes for name to set.
- * @return This builder for chaining.
- */
- public Builder setNameBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) { throw new NullPointerException(); }
- checkByteStringIsUtf8(value);
- name_ = value;
- bitField0_ |= 0x00000002;
- onChanged();
- return this;
- }
-
- private int age_ ;
- /**
- * <code>int32 age = 3;</code>
- * @return The age.
- */
- @java.lang.Override
- public int getAge() {
- return age_;
- }
- /**
- * <code>int32 age = 3;</code>
- * @param value The age to set.
- * @return This builder for chaining.
- */
- public Builder setAge(int value) {
-
- age_ = value;
- bitField0_ |= 0x00000004;
- onChanged();
- return this;
- }
- /**
- * <code>int32 age = 3;</code>
- * @return This builder for chaining.
- */
- public Builder clearAge() {
- bitField0_ = (bitField0_ & ~0x00000004);
- age_ = 0;
- onChanged();
- return this;
- }
-
- private double score_ ;
- /**
- * <code>double score = 4;</code>
- * @return The score.
- */
- @java.lang.Override
- public double getScore() {
- return score_;
- }
- /**
- * <code>double score = 4;</code>
- * @param value The score to set.
- * @return This builder for chaining.
- */
- public Builder setScore(double value) {
-
- score_ = value;
- bitField0_ |= 0x00000008;
- onChanged();
- return this;
- }
- /**
- * <code>double score = 4;</code>
- * @return This builder for chaining.
- */
- public Builder clearScore() {
- bitField0_ = (bitField0_ & ~0x00000008);
- score_ = 0D;
- onChanged();
- return this;
- }
-
- private long optionalId_ ;
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return Whether the optionalId field is set.
- */
- @java.lang.Override
- public boolean hasOptionalId() {
- return ((bitField0_ & 0x00000010) != 0);
- }
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return The optionalId.
- */
- @java.lang.Override
- public long getOptionalId() {
- return optionalId_;
- }
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @param value The optionalId to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalId(long value) {
-
- optionalId_ = value;
- bitField0_ |= 0x00000010;
- onChanged();
- return this;
- }
- /**
- * <code>optional int64 optional_id = 5;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalId() {
- bitField0_ = (bitField0_ & ~0x00000010);
- optionalId_ = 0L;
- onChanged();
- return this;
- }
-
- private int optionalAge_ ;
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return Whether the optionalAge field is set.
- */
- @java.lang.Override
- public boolean hasOptionalAge() {
- return ((bitField0_ & 0x00000020) != 0);
- }
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return The optionalAge.
- */
- @java.lang.Override
- public int getOptionalAge() {
- return optionalAge_;
- }
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @param value The optionalAge to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalAge(int value) {
-
- optionalAge_ = value;
- bitField0_ |= 0x00000020;
- onChanged();
- return this;
- }
- /**
- * <code>optional int32 optional_age = 6;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalAge() {
- bitField0_ = (bitField0_ & ~0x00000020);
- optionalAge_ = 0;
- onChanged();
- return this;
- }
- @java.lang.Override
- public final Builder setUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.setUnknownFields(unknownFields);
- }
-
- @java.lang.Override
- public final Builder mergeUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.mergeUnknownFields(unknownFields);
- }
-
-
- // @@protoc_insertion_point(builder_scope:StructMessage)
- }
-
- // @@protoc_insertion_point(class_scope:StructMessage)
- private static final com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage DEFAULT_INSTANCE;
- static {
- DEFAULT_INSTANCE = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage();
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstance() {
- return DEFAULT_INSTANCE;
- }
-
- private static final com.google.protobuf.Parser<StructMessage>
- PARSER = new com.google.protobuf.AbstractParser<StructMessage>() {
- @java.lang.Override
- public StructMessage parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- Builder builder = newBuilder();
- try {
- builder.mergeFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(builder.buildPartial());
- } catch (com.google.protobuf.UninitializedMessageException e) {
- throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(e)
- .setUnfinishedMessage(builder.buildPartial());
- }
- return builder.buildPartial();
- }
- };
-
- public static com.google.protobuf.Parser<StructMessage> parser() {
- return PARSER;
- }
-
- @java.lang.Override
- public com.google.protobuf.Parser<StructMessage> getParserForType() {
- return PARSER;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
- }
-
- public interface Proto3TypesOrBuilder extends
- // @@protoc_insertion_point(interface_extends:Proto3Types)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>int64 int64 = 1;</code>
- * @return The int64.
- */
- long getInt64();
-
- /**
- * <code>int32 int32 = 2;</code>
- * @return The int32.
- */
- int getInt32();
-
- /**
- * <code>string text = 3;</code>
- * @return The text.
- */
- java.lang.String getText();
- /**
- * <code>string text = 3;</code>
- * @return The bytes for text.
- */
- com.google.protobuf.ByteString
- getTextBytes();
-
- /**
- * <code>bytes bytes = 4;</code>
- * @return The bytes.
- */
- com.google.protobuf.ByteString getBytes();
-
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enum numeric value on the wire for enumVal.
- */
- int getEnumValValue();
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enumVal.
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal();
-
- /**
- * <code>.StructMessage message = 6;</code>
- * @return Whether the message field is set.
- */
- boolean hasMessage();
- /**
- * <code>.StructMessage message = 6;</code>
- * @return The message.
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage();
- /**
- * <code>.StructMessage message = 6;</code>
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder();
-
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return Whether the optionalInt64 field is set.
- */
- boolean hasOptionalInt64();
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return The optionalInt64.
- */
- long getOptionalInt64();
-
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return Whether the optionalInt32 field is set.
- */
- boolean hasOptionalInt32();
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return The optionalInt32.
- */
- int getOptionalInt32();
-
- /**
- * <code>optional string optional_text = 9;</code>
- * @return Whether the optionalText field is set.
- */
- boolean hasOptionalText();
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The optionalText.
- */
- java.lang.String getOptionalText();
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The bytes for optionalText.
- */
- com.google.protobuf.ByteString
- getOptionalTextBytes();
-
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return Whether the optionalBytes field is set.
- */
- boolean hasOptionalBytes();
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return The optionalBytes.
- */
- com.google.protobuf.ByteString getOptionalBytes();
-
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return Whether the optionalEnumVal field is set.
- */
- boolean hasOptionalEnumVal();
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The enum numeric value on the wire for optionalEnumVal.
- */
- int getOptionalEnumValValue();
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The optionalEnumVal.
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal();
-
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return Whether the optionalMessage field is set.
- */
- boolean hasOptionalMessage();
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return The optionalMessage.
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage();
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder();
-
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return A list containing the repeatedInt64.
- */
- java.util.List<java.lang.Long> getRepeatedInt64List();
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return The count of repeatedInt64.
- */
- int getRepeatedInt64Count();
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt64 at the given index.
- */
- long getRepeatedInt64(int index);
-
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return A list containing the repeatedInt32.
- */
- java.util.List<java.lang.Integer> getRepeatedInt32List();
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return The count of repeatedInt32.
- */
- int getRepeatedInt32Count();
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt32 at the given index.
- */
- int getRepeatedInt32(int index);
-
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage>
- getRepeatedMessageList();
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index);
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- int getRepeatedMessageCount();
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getRepeatedMessageOrBuilderList();
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
- int index);
- }
- /**
- * Protobuf type {@code Proto3Types}
- */
- public static final class Proto3Types extends
- com.google.protobuf.GeneratedMessageV3 implements
- // @@protoc_insertion_point(message_implements:Proto3Types)
- Proto3TypesOrBuilder {
- private static final long serialVersionUID = 0L;
- // Use Proto3Types.newBuilder() to construct.
- private Proto3Types(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
- super(builder);
- }
- private Proto3Types() {
- text_ = "";
- bytes_ = com.google.protobuf.ByteString.EMPTY;
- enumVal_ = 0;
- optionalText_ = "";
- optionalBytes_ = com.google.protobuf.ByteString.EMPTY;
- optionalEnumVal_ = 0;
- repeatedInt64_ = emptyLongList();
- repeatedInt32_ = emptyIntList();
- repeatedMessage_ = java.util.Collections.emptyList();
- }
-
- @java.lang.Override
- @SuppressWarnings({"unused"})
- protected java.lang.Object newInstance(
- UnusedPrivateParameter unused) {
- return new Proto3Types();
- }
-
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
- }
-
- @java.lang.Override
- protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.Builder.class);
- }
-
- /**
- * Protobuf enum {@code Proto3Types.NestedEnum}
- */
- public enum NestedEnum
- implements com.google.protobuf.ProtocolMessageEnum {
- /**
- * <code>NOTHING = 0;</code>
- */
- NOTHING(0),
- /**
- * <code>FIRST = 1;</code>
- */
- FIRST(1),
- /**
- * <code>SECOND = 2;</code>
- */
- SECOND(2),
- UNRECOGNIZED(-1),
- ;
-
- /**
- * <code>NOTHING = 0;</code>
- */
- public static final int NOTHING_VALUE = 0;
- /**
- * <code>FIRST = 1;</code>
- */
- public static final int FIRST_VALUE = 1;
- /**
- * <code>SECOND = 2;</code>
- */
- public static final int SECOND_VALUE = 2;
-
-
- public final int getNumber() {
- if (this == UNRECOGNIZED) {
- throw new java.lang.IllegalArgumentException(
- "Can't get the number of an unknown enum value.");
- }
- return value;
- }
-
- /**
- * @param value The numeric wire value of the corresponding enum entry.
- * @return The enum associated with the given numeric wire value.
- * @deprecated Use {@link #forNumber(int)} instead.
- */
- @java.lang.Deprecated
- public static NestedEnum valueOf(int value) {
- return forNumber(value);
- }
-
- /**
- * @param value The numeric wire value of the corresponding enum entry.
- * @return The enum associated with the given numeric wire value.
- */
- public static NestedEnum forNumber(int value) {
- switch (value) {
- case 0: return NOTHING;
- case 1: return FIRST;
- case 2: return SECOND;
- default: return null;
- }
- }
-
- public static com.google.protobuf.Internal.EnumLiteMap<NestedEnum>
- internalGetValueMap() {
- return internalValueMap;
- }
- private static final com.google.protobuf.Internal.EnumLiteMap<
- NestedEnum> internalValueMap =
- new com.google.protobuf.Internal.EnumLiteMap<NestedEnum>() {
- public NestedEnum findValueByNumber(int number) {
- return NestedEnum.forNumber(number);
- }
- };
-
- public final com.google.protobuf.Descriptors.EnumValueDescriptor
- getValueDescriptor() {
- if (this == UNRECOGNIZED) {
- throw new java.lang.IllegalStateException(
- "Can't get the descriptor of an unrecognized enum value.");
- }
- return getDescriptor().getValues().get(ordinal());
- }
- public final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptorForType() {
- return getDescriptor();
- }
- public static final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptor() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDescriptor().getEnumTypes().get(0);
- }
-
- private static final NestedEnum[] VALUES = values();
-
- public static NestedEnum valueOf(
- com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
- if (desc.getType() != getDescriptor()) {
- throw new java.lang.IllegalArgumentException(
- "EnumValueDescriptor is not for this type.");
- }
- if (desc.getIndex() == -1) {
- return UNRECOGNIZED;
- }
- return VALUES[desc.getIndex()];
- }
-
- private final int value;
-
- private NestedEnum(int value) {
- this.value = value;
- }
-
- // @@protoc_insertion_point(enum_scope:Proto3Types.NestedEnum)
- }
-
- private int bitField0_;
- public static final int INT64_FIELD_NUMBER = 1;
- private long int64_ = 0L;
- /**
- * <code>int64 int64 = 1;</code>
- * @return The int64.
- */
- @java.lang.Override
- public long getInt64() {
- return int64_;
- }
-
- public static final int INT32_FIELD_NUMBER = 2;
- private int int32_ = 0;
- /**
- * <code>int32 int32 = 2;</code>
- * @return The int32.
- */
- @java.lang.Override
- public int getInt32() {
- return int32_;
- }
-
- public static final int TEXT_FIELD_NUMBER = 3;
- @SuppressWarnings("serial")
- private volatile java.lang.Object text_ = "";
- /**
- * <code>string text = 3;</code>
- * @return The text.
- */
- @java.lang.Override
- public java.lang.String getText() {
- java.lang.Object ref = text_;
- 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();
- text_ = s;
- return s;
- }
- }
- /**
- * <code>string text = 3;</code>
- * @return The bytes for text.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString
- getTextBytes() {
- java.lang.Object ref = text_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- text_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int BYTES_FIELD_NUMBER = 4;
- private com.google.protobuf.ByteString bytes_ = com.google.protobuf.ByteString.EMPTY;
- /**
- * <code>bytes bytes = 4;</code>
- * @return The bytes.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString getBytes() {
- return bytes_;
- }
-
- public static final int ENUM_VAL_FIELD_NUMBER = 5;
- private int enumVal_ = 0;
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enum numeric value on the wire for enumVal.
- */
- @java.lang.Override public int getEnumValValue() {
- return enumVal_;
- }
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enumVal.
- */
- @java.lang.Override public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(enumVal_);
- return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
- }
-
- public static final int MESSAGE_FIELD_NUMBER = 6;
- private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage message_;
- /**
- * <code>.StructMessage message = 6;</code>
- * @return Whether the message field is set.
- */
- @java.lang.Override
- public boolean hasMessage() {
- return message_ != null;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- * @return The message.
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage() {
- return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder() {
- return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
- }
-
- public static final int OPTIONAL_INT64_FIELD_NUMBER = 7;
- private long optionalInt64_ = 0L;
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return Whether the optionalInt64 field is set.
- */
- @java.lang.Override
- public boolean hasOptionalInt64() {
- return ((bitField0_ & 0x00000001) != 0);
- }
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return The optionalInt64.
- */
- @java.lang.Override
- public long getOptionalInt64() {
- return optionalInt64_;
- }
-
- public static final int OPTIONAL_INT32_FIELD_NUMBER = 8;
- private int optionalInt32_ = 0;
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return Whether the optionalInt32 field is set.
- */
- @java.lang.Override
- public boolean hasOptionalInt32() {
- return ((bitField0_ & 0x00000002) != 0);
- }
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return The optionalInt32.
- */
- @java.lang.Override
- public int getOptionalInt32() {
- return optionalInt32_;
- }
-
- public static final int OPTIONAL_TEXT_FIELD_NUMBER = 9;
- @SuppressWarnings("serial")
- private volatile java.lang.Object optionalText_ = "";
- /**
- * <code>optional string optional_text = 9;</code>
- * @return Whether the optionalText field is set.
- */
- @java.lang.Override
- public boolean hasOptionalText() {
- return ((bitField0_ & 0x00000004) != 0);
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The optionalText.
- */
- @java.lang.Override
- public java.lang.String getOptionalText() {
- java.lang.Object ref = optionalText_;
- 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();
- optionalText_ = s;
- return s;
- }
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The bytes for optionalText.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString
- getOptionalTextBytes() {
- java.lang.Object ref = optionalText_;
- if (ref instanceof java.lang.String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- optionalText_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- public static final int OPTIONAL_BYTES_FIELD_NUMBER = 10;
- private com.google.protobuf.ByteString optionalBytes_ = com.google.protobuf.ByteString.EMPTY;
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return Whether the optionalBytes field is set.
- */
- @java.lang.Override
- public boolean hasOptionalBytes() {
- return ((bitField0_ & 0x00000008) != 0);
- }
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return The optionalBytes.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString getOptionalBytes() {
- return optionalBytes_;
- }
-
- public static final int OPTIONAL_ENUM_VAL_FIELD_NUMBER = 11;
- private int optionalEnumVal_ = 0;
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return Whether the optionalEnumVal field is set.
- */
- @java.lang.Override public boolean hasOptionalEnumVal() {
- return ((bitField0_ & 0x00000010) != 0);
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The enum numeric value on the wire for optionalEnumVal.
- */
- @java.lang.Override public int getOptionalEnumValValue() {
- return optionalEnumVal_;
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The optionalEnumVal.
- */
- @java.lang.Override public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(optionalEnumVal_);
- return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
- }
-
- public static final int OPTIONAL_MESSAGE_FIELD_NUMBER = 12;
- private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage optionalMessage_;
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return Whether the optionalMessage field is set.
- */
- @java.lang.Override
- public boolean hasOptionalMessage() {
- return ((bitField0_ & 0x00000020) != 0);
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return The optionalMessage.
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage() {
- return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder() {
- return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
- }
-
- public static final int REPEATED_INT64_FIELD_NUMBER = 13;
- @SuppressWarnings("serial")
- private com.google.protobuf.Internal.LongList repeatedInt64_;
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return A list containing the repeatedInt64.
- */
- @java.lang.Override
- public java.util.List<java.lang.Long>
- getRepeatedInt64List() {
- return repeatedInt64_;
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return The count of repeatedInt64.
- */
- public int getRepeatedInt64Count() {
- return repeatedInt64_.size();
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt64 at the given index.
- */
- public long getRepeatedInt64(int index) {
- return repeatedInt64_.getLong(index);
- }
- private int repeatedInt64MemoizedSerializedSize = -1;
-
- public static final int REPEATED_INT32_FIELD_NUMBER = 14;
- @SuppressWarnings("serial")
- private com.google.protobuf.Internal.IntList repeatedInt32_;
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return A list containing the repeatedInt32.
- */
- @java.lang.Override
- public java.util.List<java.lang.Integer>
- getRepeatedInt32List() {
- return repeatedInt32_;
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return The count of repeatedInt32.
- */
- public int getRepeatedInt32Count() {
- return repeatedInt32_.size();
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt32 at the given index.
- */
- public int getRepeatedInt32(int index) {
- return repeatedInt32_.getInt(index);
- }
- private int repeatedInt32MemoizedSerializedSize = -1;
-
- public static final int REPEATED_MESSAGE_FIELD_NUMBER = 15;
- @SuppressWarnings("serial")
- private java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> repeatedMessage_;
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- @java.lang.Override
- public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> getRepeatedMessageList() {
- return repeatedMessage_;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- @java.lang.Override
- public java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getRepeatedMessageOrBuilderList() {
- return repeatedMessage_;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- @java.lang.Override
- public int getRepeatedMessageCount() {
- return repeatedMessage_.size();
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index) {
- return repeatedMessage_.get(index);
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
- int index) {
- return repeatedMessage_.get(index);
- }
-
- private byte memoizedIsInitialized = -1;
- @java.lang.Override
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) return true;
- if (isInitialized == 0) return false;
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- @java.lang.Override
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- getSerializedSize();
- if (int64_ != 0L) {
- output.writeInt64(1, int64_);
- }
- if (int32_ != 0) {
- output.writeInt32(2, int32_);
- }
- if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(text_)) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 3, text_);
- }
- if (!bytes_.isEmpty()) {
- output.writeBytes(4, bytes_);
- }
- if (enumVal_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.NOTHING.getNumber()) {
- output.writeEnum(5, enumVal_);
- }
- if (message_ != null) {
- output.writeMessage(6, getMessage());
- }
- if (((bitField0_ & 0x00000001) != 0)) {
- output.writeInt64(7, optionalInt64_);
- }
- if (((bitField0_ & 0x00000002) != 0)) {
- output.writeInt32(8, optionalInt32_);
- }
- if (((bitField0_ & 0x00000004) != 0)) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 9, optionalText_);
- }
- if (((bitField0_ & 0x00000008) != 0)) {
- output.writeBytes(10, optionalBytes_);
- }
- if (((bitField0_ & 0x00000010) != 0)) {
- output.writeEnum(11, optionalEnumVal_);
- }
- if (((bitField0_ & 0x00000020) != 0)) {
- output.writeMessage(12, getOptionalMessage());
- }
- if (getRepeatedInt64List().size() > 0) {
- output.writeUInt32NoTag(106);
- output.writeUInt32NoTag(repeatedInt64MemoizedSerializedSize);
- }
- for (int i = 0; i < repeatedInt64_.size(); i++) {
- output.writeInt64NoTag(repeatedInt64_.getLong(i));
- }
- if (getRepeatedInt32List().size() > 0) {
- output.writeUInt32NoTag(114);
- output.writeUInt32NoTag(repeatedInt32MemoizedSerializedSize);
- }
- for (int i = 0; i < repeatedInt32_.size(); i++) {
- output.writeInt32NoTag(repeatedInt32_.getInt(i));
- }
- for (int i = 0; i < repeatedMessage_.size(); i++) {
- output.writeMessage(15, repeatedMessage_.get(i));
- }
- getUnknownFields().writeTo(output);
- }
-
- @java.lang.Override
- public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) return size;
-
- size = 0;
- if (int64_ != 0L) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(1, int64_);
- }
- if (int32_ != 0) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(2, int32_);
- }
- if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(text_)) {
- size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, text_);
- }
- if (!bytes_.isEmpty()) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(4, bytes_);
- }
- if (enumVal_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.NOTHING.getNumber()) {
- size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(5, enumVal_);
- }
- if (message_ != null) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(6, getMessage());
- }
- if (((bitField0_ & 0x00000001) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(7, optionalInt64_);
- }
- if (((bitField0_ & 0x00000002) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(8, optionalInt32_);
- }
- if (((bitField0_ & 0x00000004) != 0)) {
- size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, optionalText_);
- }
- if (((bitField0_ & 0x00000008) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(10, optionalBytes_);
- }
- if (((bitField0_ & 0x00000010) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(11, optionalEnumVal_);
- }
- if (((bitField0_ & 0x00000020) != 0)) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(12, getOptionalMessage());
- }
- {
- int dataSize = 0;
- for (int i = 0; i < repeatedInt64_.size(); i++) {
- dataSize += com.google.protobuf.CodedOutputStream
- .computeInt64SizeNoTag(repeatedInt64_.getLong(i));
- }
- size += dataSize;
- if (!getRepeatedInt64List().isEmpty()) {
- size += 1;
- size += com.google.protobuf.CodedOutputStream
- .computeInt32SizeNoTag(dataSize);
- }
- repeatedInt64MemoizedSerializedSize = dataSize;
- }
- {
- int dataSize = 0;
- for (int i = 0; i < repeatedInt32_.size(); i++) {
- dataSize += com.google.protobuf.CodedOutputStream
- .computeInt32SizeNoTag(repeatedInt32_.getInt(i));
- }
- size += dataSize;
- if (!getRepeatedInt32List().isEmpty()) {
- size += 1;
- size += com.google.protobuf.CodedOutputStream
- .computeInt32SizeNoTag(dataSize);
- }
- repeatedInt32MemoizedSerializedSize = dataSize;
- }
- for (int i = 0; i < repeatedMessage_.size(); i++) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(15, repeatedMessage_.get(i));
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSize = size;
- return size;
- }
-
- @java.lang.Override
- public boolean equals(final java.lang.Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types)) {
- return super.equals(obj);
- }
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types other = (com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types) obj;
-
- if (getInt64()
- != other.getInt64()) return false;
- if (getInt32()
- != other.getInt32()) return false;
- if (!getText()
- .equals(other.getText())) return false;
- if (!getBytes()
- .equals(other.getBytes())) return false;
- if (enumVal_ != other.enumVal_) return false;
- if (hasMessage() != other.hasMessage()) return false;
- if (hasMessage()) {
- if (!getMessage()
- .equals(other.getMessage())) return false;
- }
- if (hasOptionalInt64() != other.hasOptionalInt64()) return false;
- if (hasOptionalInt64()) {
- if (getOptionalInt64()
- != other.getOptionalInt64()) return false;
- }
- if (hasOptionalInt32() != other.hasOptionalInt32()) return false;
- if (hasOptionalInt32()) {
- if (getOptionalInt32()
- != other.getOptionalInt32()) return false;
- }
- if (hasOptionalText() != other.hasOptionalText()) return false;
- if (hasOptionalText()) {
- if (!getOptionalText()
- .equals(other.getOptionalText())) return false;
- }
- if (hasOptionalBytes() != other.hasOptionalBytes()) return false;
- if (hasOptionalBytes()) {
- if (!getOptionalBytes()
- .equals(other.getOptionalBytes())) return false;
- }
- if (hasOptionalEnumVal() != other.hasOptionalEnumVal()) return false;
- if (hasOptionalEnumVal()) {
- if (optionalEnumVal_ != other.optionalEnumVal_) return false;
- }
- if (hasOptionalMessage() != other.hasOptionalMessage()) return false;
- if (hasOptionalMessage()) {
- if (!getOptionalMessage()
- .equals(other.getOptionalMessage())) return false;
- }
- if (!getRepeatedInt64List()
- .equals(other.getRepeatedInt64List())) return false;
- if (!getRepeatedInt32List()
- .equals(other.getRepeatedInt32List())) return false;
- if (!getRepeatedMessageList()
- .equals(other.getRepeatedMessageList())) return false;
- if (!getUnknownFields().equals(other.getUnknownFields())) return false;
- return true;
- }
-
- @java.lang.Override
- public int hashCode() {
- if (memoizedHashCode != 0) {
- return memoizedHashCode;
- }
- int hash = 41;
- hash = (19 * hash) + getDescriptor().hashCode();
- hash = (37 * hash) + INT64_FIELD_NUMBER;
- hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
- getInt64());
- hash = (37 * hash) + INT32_FIELD_NUMBER;
- hash = (53 * hash) + getInt32();
- hash = (37 * hash) + TEXT_FIELD_NUMBER;
- hash = (53 * hash) + getText().hashCode();
- hash = (37 * hash) + BYTES_FIELD_NUMBER;
- hash = (53 * hash) + getBytes().hashCode();
- hash = (37 * hash) + ENUM_VAL_FIELD_NUMBER;
- hash = (53 * hash) + enumVal_;
- if (hasMessage()) {
- hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
- hash = (53 * hash) + getMessage().hashCode();
- }
- if (hasOptionalInt64()) {
- hash = (37 * hash) + OPTIONAL_INT64_FIELD_NUMBER;
- hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
- getOptionalInt64());
- }
- if (hasOptionalInt32()) {
- hash = (37 * hash) + OPTIONAL_INT32_FIELD_NUMBER;
- hash = (53 * hash) + getOptionalInt32();
- }
- if (hasOptionalText()) {
- hash = (37 * hash) + OPTIONAL_TEXT_FIELD_NUMBER;
- hash = (53 * hash) + getOptionalText().hashCode();
- }
- if (hasOptionalBytes()) {
- hash = (37 * hash) + OPTIONAL_BYTES_FIELD_NUMBER;
- hash = (53 * hash) + getOptionalBytes().hashCode();
- }
- if (hasOptionalEnumVal()) {
- hash = (37 * hash) + OPTIONAL_ENUM_VAL_FIELD_NUMBER;
- hash = (53 * hash) + optionalEnumVal_;
- }
- if (hasOptionalMessage()) {
- hash = (37 * hash) + OPTIONAL_MESSAGE_FIELD_NUMBER;
- hash = (53 * hash) + getOptionalMessage().hashCode();
- }
- if (getRepeatedInt64Count() > 0) {
- hash = (37 * hash) + REPEATED_INT64_FIELD_NUMBER;
- hash = (53 * hash) + getRepeatedInt64List().hashCode();
- }
- if (getRepeatedInt32Count() > 0) {
- hash = (37 * hash) + REPEATED_INT32_FIELD_NUMBER;
- hash = (53 * hash) + getRepeatedInt32List().hashCode();
- }
- if (getRepeatedMessageCount() > 0) {
- hash = (37 * hash) + REPEATED_MESSAGE_FIELD_NUMBER;
- hash = (53 * hash) + getRepeatedMessageList().hashCode();
- }
- hash = (29 * hash) + getUnknownFields().hashCode();
- memoizedHashCode = hash;
- return hash;
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- java.nio.ByteBuffer data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- java.nio.ByteBuffer data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input);
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- @java.lang.Override
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder() {
- return DEFAULT_INSTANCE.toBuilder();
- }
- public static Builder newBuilder(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types prototype) {
- return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
- }
- @java.lang.Override
- public Builder toBuilder() {
- return this == DEFAULT_INSTANCE
- ? new Builder() : new Builder().mergeFrom(this);
- }
-
- @java.lang.Override
- protected Builder newBuilderForType(
- com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
- /**
- * Protobuf type {@code Proto3Types}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:Proto3Types)
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3TypesOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
- }
-
- @java.lang.Override
- protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.Builder.class);
- }
-
- // Construct using com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessageV3
- .alwaysUseFieldBuilders) {
- getMessageFieldBuilder();
- getOptionalMessageFieldBuilder();
- getRepeatedMessageFieldBuilder();
- }
- }
- @java.lang.Override
- public Builder clear() {
- super.clear();
- bitField0_ = 0;
- int64_ = 0L;
- int32_ = 0;
- text_ = "";
- bytes_ = com.google.protobuf.ByteString.EMPTY;
- enumVal_ = 0;
- message_ = null;
- if (messageBuilder_ != null) {
- messageBuilder_.dispose();
- messageBuilder_ = null;
- }
- optionalInt64_ = 0L;
- optionalInt32_ = 0;
- optionalText_ = "";
- optionalBytes_ = com.google.protobuf.ByteString.EMPTY;
- optionalEnumVal_ = 0;
- optionalMessage_ = null;
- if (optionalMessageBuilder_ != null) {
- optionalMessageBuilder_.dispose();
- optionalMessageBuilder_ = null;
- }
- repeatedInt64_ = emptyLongList();
- repeatedInt32_ = emptyIntList();
- if (repeatedMessageBuilder_ == null) {
- repeatedMessage_ = java.util.Collections.emptyList();
- } else {
- repeatedMessage_ = null;
- repeatedMessageBuilder_.clear();
- }
- bitField0_ = (bitField0_ & ~0x00004000);
- return this;
- }
-
- @java.lang.Override
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstanceForType() {
- return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDefaultInstance();
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types build() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types buildPartial() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types(this);
- buildPartialRepeatedFields(result);
- if (bitField0_ != 0) { buildPartial0(result); }
- onBuilt();
- return result;
- }
-
- private void buildPartialRepeatedFields(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result) {
- if (((bitField0_ & 0x00001000) != 0)) {
- repeatedInt64_.makeImmutable();
- bitField0_ = (bitField0_ & ~0x00001000);
- }
- result.repeatedInt64_ = repeatedInt64_;
- if (((bitField0_ & 0x00002000) != 0)) {
- repeatedInt32_.makeImmutable();
- bitField0_ = (bitField0_ & ~0x00002000);
- }
- result.repeatedInt32_ = repeatedInt32_;
- if (repeatedMessageBuilder_ == null) {
- if (((bitField0_ & 0x00004000) != 0)) {
- repeatedMessage_ = java.util.Collections.unmodifiableList(repeatedMessage_);
- bitField0_ = (bitField0_ & ~0x00004000);
- }
- result.repeatedMessage_ = repeatedMessage_;
- } else {
- result.repeatedMessage_ = repeatedMessageBuilder_.build();
- }
- }
-
- private void buildPartial0(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result) {
- int from_bitField0_ = bitField0_;
- if (((from_bitField0_ & 0x00000001) != 0)) {
- result.int64_ = int64_;
- }
- if (((from_bitField0_ & 0x00000002) != 0)) {
- result.int32_ = int32_;
- }
- if (((from_bitField0_ & 0x00000004) != 0)) {
- result.text_ = text_;
- }
- if (((from_bitField0_ & 0x00000008) != 0)) {
- result.bytes_ = bytes_;
- }
- if (((from_bitField0_ & 0x00000010) != 0)) {
- result.enumVal_ = enumVal_;
- }
- if (((from_bitField0_ & 0x00000020) != 0)) {
- result.message_ = messageBuilder_ == null
- ? message_
- : messageBuilder_.build();
- }
- int to_bitField0_ = 0;
- if (((from_bitField0_ & 0x00000040) != 0)) {
- result.optionalInt64_ = optionalInt64_;
- to_bitField0_ |= 0x00000001;
- }
- if (((from_bitField0_ & 0x00000080) != 0)) {
- result.optionalInt32_ = optionalInt32_;
- to_bitField0_ |= 0x00000002;
- }
- if (((from_bitField0_ & 0x00000100) != 0)) {
- result.optionalText_ = optionalText_;
- to_bitField0_ |= 0x00000004;
- }
- if (((from_bitField0_ & 0x00000200) != 0)) {
- result.optionalBytes_ = optionalBytes_;
- to_bitField0_ |= 0x00000008;
- }
- if (((from_bitField0_ & 0x00000400) != 0)) {
- result.optionalEnumVal_ = optionalEnumVal_;
- to_bitField0_ |= 0x00000010;
- }
- if (((from_bitField0_ & 0x00000800) != 0)) {
- result.optionalMessage_ = optionalMessageBuilder_ == null
- ? optionalMessage_
- : optionalMessageBuilder_.build();
- to_bitField0_ |= 0x00000020;
- }
- result.bitField0_ |= to_bitField0_;
- }
-
- @java.lang.Override
- public Builder clone() {
- return super.clone();
- }
- @java.lang.Override
- public Builder setField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- java.lang.Object value) {
- return super.setField(field, value);
- }
- @java.lang.Override
- public Builder clearField(
- com.google.protobuf.Descriptors.FieldDescriptor field) {
- return super.clearField(field);
- }
- @java.lang.Override
- public Builder clearOneof(
- com.google.protobuf.Descriptors.OneofDescriptor oneof) {
- return super.clearOneof(oneof);
- }
- @java.lang.Override
- public Builder setRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- int index, java.lang.Object value) {
- return super.setRepeatedField(field, index, value);
- }
- @java.lang.Override
- public Builder addRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- java.lang.Object value) {
- return super.addRepeatedField(field, value);
- }
- @java.lang.Override
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types) {
- return mergeFrom((com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types other) {
- if (other == com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDefaultInstance()) return this;
- if (other.getInt64() != 0L) {
- setInt64(other.getInt64());
- }
- if (other.getInt32() != 0) {
- setInt32(other.getInt32());
- }
- if (!other.getText().isEmpty()) {
- text_ = other.text_;
- bitField0_ |= 0x00000004;
- onChanged();
- }
- if (other.getBytes() != com.google.protobuf.ByteString.EMPTY) {
- setBytes(other.getBytes());
- }
- if (other.enumVal_ != 0) {
- setEnumValValue(other.getEnumValValue());
- }
- if (other.hasMessage()) {
- mergeMessage(other.getMessage());
- }
- if (other.hasOptionalInt64()) {
- setOptionalInt64(other.getOptionalInt64());
- }
- if (other.hasOptionalInt32()) {
- setOptionalInt32(other.getOptionalInt32());
- }
- if (other.hasOptionalText()) {
- optionalText_ = other.optionalText_;
- bitField0_ |= 0x00000100;
- onChanged();
- }
- if (other.hasOptionalBytes()) {
- setOptionalBytes(other.getOptionalBytes());
- }
- if (other.hasOptionalEnumVal()) {
- setOptionalEnumVal(other.getOptionalEnumVal());
- }
- if (other.hasOptionalMessage()) {
- mergeOptionalMessage(other.getOptionalMessage());
- }
- if (!other.repeatedInt64_.isEmpty()) {
- if (repeatedInt64_.isEmpty()) {
- repeatedInt64_ = other.repeatedInt64_;
- bitField0_ = (bitField0_ & ~0x00001000);
- } else {
- ensureRepeatedInt64IsMutable();
- repeatedInt64_.addAll(other.repeatedInt64_);
- }
- onChanged();
- }
- if (!other.repeatedInt32_.isEmpty()) {
- if (repeatedInt32_.isEmpty()) {
- repeatedInt32_ = other.repeatedInt32_;
- bitField0_ = (bitField0_ & ~0x00002000);
- } else {
- ensureRepeatedInt32IsMutable();
- repeatedInt32_.addAll(other.repeatedInt32_);
- }
- onChanged();
- }
- if (repeatedMessageBuilder_ == null) {
- if (!other.repeatedMessage_.isEmpty()) {
- if (repeatedMessage_.isEmpty()) {
- repeatedMessage_ = other.repeatedMessage_;
- bitField0_ = (bitField0_ & ~0x00004000);
- } else {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.addAll(other.repeatedMessage_);
- }
- onChanged();
- }
- } else {
- if (!other.repeatedMessage_.isEmpty()) {
- if (repeatedMessageBuilder_.isEmpty()) {
- repeatedMessageBuilder_.dispose();
- repeatedMessageBuilder_ = null;
- repeatedMessage_ = other.repeatedMessage_;
- bitField0_ = (bitField0_ & ~0x00004000);
- repeatedMessageBuilder_ =
- com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
- getRepeatedMessageFieldBuilder() : null;
- } else {
- repeatedMessageBuilder_.addAllMessages(other.repeatedMessage_);
- }
- }
- }
- this.mergeUnknownFields(other.getUnknownFields());
- onChanged();
- return this;
- }
-
- @java.lang.Override
- public final boolean isInitialized() {
- return true;
- }
-
- @java.lang.Override
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- if (extensionRegistry == null) {
- throw new java.lang.NullPointerException();
- }
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- case 8: {
- int64_ = input.readInt64();
- bitField0_ |= 0x00000001;
- break;
- } // case 8
- case 16: {
- int32_ = input.readInt32();
- bitField0_ |= 0x00000002;
- break;
- } // case 16
- case 26: {
- text_ = input.readStringRequireUtf8();
- bitField0_ |= 0x00000004;
- break;
- } // case 26
- case 34: {
- bytes_ = input.readBytes();
- bitField0_ |= 0x00000008;
- break;
- } // case 34
- case 40: {
- enumVal_ = input.readEnum();
- bitField0_ |= 0x00000010;
- break;
- } // case 40
- case 50: {
- input.readMessage(
- getMessageFieldBuilder().getBuilder(),
- extensionRegistry);
- bitField0_ |= 0x00000020;
- break;
- } // case 50
- case 56: {
- optionalInt64_ = input.readInt64();
- bitField0_ |= 0x00000040;
- break;
- } // case 56
- case 64: {
- optionalInt32_ = input.readInt32();
- bitField0_ |= 0x00000080;
- break;
- } // case 64
- case 74: {
- optionalText_ = input.readStringRequireUtf8();
- bitField0_ |= 0x00000100;
- break;
- } // case 74
- case 82: {
- optionalBytes_ = input.readBytes();
- bitField0_ |= 0x00000200;
- break;
- } // case 82
- case 88: {
- optionalEnumVal_ = input.readEnum();
- bitField0_ |= 0x00000400;
- break;
- } // case 88
- case 98: {
- input.readMessage(
- getOptionalMessageFieldBuilder().getBuilder(),
- extensionRegistry);
- bitField0_ |= 0x00000800;
- break;
- } // case 98
- case 104: {
- long v = input.readInt64();
- ensureRepeatedInt64IsMutable();
- repeatedInt64_.addLong(v);
- break;
- } // case 104
- case 106: {
- int length = input.readRawVarint32();
- int limit = input.pushLimit(length);
- ensureRepeatedInt64IsMutable();
- while (input.getBytesUntilLimit() > 0) {
- repeatedInt64_.addLong(input.readInt64());
- }
- input.popLimit(limit);
- break;
- } // case 106
- case 112: {
- int v = input.readInt32();
- ensureRepeatedInt32IsMutable();
- repeatedInt32_.addInt(v);
- break;
- } // case 112
- case 114: {
- int length = input.readRawVarint32();
- int limit = input.pushLimit(length);
- ensureRepeatedInt32IsMutable();
- while (input.getBytesUntilLimit() > 0) {
- repeatedInt32_.addInt(input.readInt32());
- }
- input.popLimit(limit);
- break;
- } // case 114
- case 122: {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage m =
- input.readMessage(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.parser(),
- extensionRegistry);
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.add(m);
- } else {
- repeatedMessageBuilder_.addMessage(m);
- }
- break;
- } // case 122
- default: {
- if (!super.parseUnknownField(input, extensionRegistry, tag)) {
- done = true; // was an endgroup tag
- }
- break;
- } // default:
- } // switch (tag)
- } // while (!done)
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.unwrapIOException();
- } finally {
- onChanged();
- } // finally
- return this;
- }
- private int bitField0_;
-
- private long int64_ ;
- /**
- * <code>int64 int64 = 1;</code>
- * @return The int64.
- */
- @java.lang.Override
- public long getInt64() {
- return int64_;
- }
- /**
- * <code>int64 int64 = 1;</code>
- * @param value The int64 to set.
- * @return This builder for chaining.
- */
- public Builder setInt64(long value) {
-
- int64_ = value;
- bitField0_ |= 0x00000001;
- onChanged();
- return this;
- }
- /**
- * <code>int64 int64 = 1;</code>
- * @return This builder for chaining.
- */
- public Builder clearInt64() {
- bitField0_ = (bitField0_ & ~0x00000001);
- int64_ = 0L;
- onChanged();
- return this;
- }
-
- private int int32_ ;
- /**
- * <code>int32 int32 = 2;</code>
- * @return The int32.
- */
- @java.lang.Override
- public int getInt32() {
- return int32_;
- }
- /**
- * <code>int32 int32 = 2;</code>
- * @param value The int32 to set.
- * @return This builder for chaining.
- */
- public Builder setInt32(int value) {
-
- int32_ = value;
- bitField0_ |= 0x00000002;
- onChanged();
- return this;
- }
- /**
- * <code>int32 int32 = 2;</code>
- * @return This builder for chaining.
- */
- public Builder clearInt32() {
- bitField0_ = (bitField0_ & ~0x00000002);
- int32_ = 0;
- onChanged();
- return this;
- }
-
- private java.lang.Object text_ = "";
- /**
- * <code>string text = 3;</code>
- * @return The text.
- */
- public java.lang.String getText() {
- java.lang.Object ref = text_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- text_ = s;
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>string text = 3;</code>
- * @return The bytes for text.
- */
- public com.google.protobuf.ByteString
- getTextBytes() {
- java.lang.Object ref = text_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- text_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>string text = 3;</code>
- * @param value The text to set.
- * @return This builder for chaining.
- */
- public Builder setText(
- java.lang.String value) {
- if (value == null) { throw new NullPointerException(); }
- text_ = value;
- bitField0_ |= 0x00000004;
- onChanged();
- return this;
- }
- /**
- * <code>string text = 3;</code>
- * @return This builder for chaining.
- */
- public Builder clearText() {
- text_ = getDefaultInstance().getText();
- bitField0_ = (bitField0_ & ~0x00000004);
- onChanged();
- return this;
- }
- /**
- * <code>string text = 3;</code>
- * @param value The bytes for text to set.
- * @return This builder for chaining.
- */
- public Builder setTextBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) { throw new NullPointerException(); }
- checkByteStringIsUtf8(value);
- text_ = value;
- bitField0_ |= 0x00000004;
- onChanged();
- return this;
- }
-
- private com.google.protobuf.ByteString bytes_ = com.google.protobuf.ByteString.EMPTY;
- /**
- * <code>bytes bytes = 4;</code>
- * @return The bytes.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString getBytes() {
- return bytes_;
- }
- /**
- * <code>bytes bytes = 4;</code>
- * @param value The bytes to set.
- * @return This builder for chaining.
- */
- public Builder setBytes(com.google.protobuf.ByteString value) {
- if (value == null) { throw new NullPointerException(); }
- bytes_ = value;
- bitField0_ |= 0x00000008;
- onChanged();
- return this;
- }
- /**
- * <code>bytes bytes = 4;</code>
- * @return This builder for chaining.
- */
- public Builder clearBytes() {
- bitField0_ = (bitField0_ & ~0x00000008);
- bytes_ = getDefaultInstance().getBytes();
- onChanged();
- return this;
- }
-
- private int enumVal_ = 0;
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enum numeric value on the wire for enumVal.
- */
- @java.lang.Override public int getEnumValValue() {
- return enumVal_;
- }
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @param value The enum numeric value on the wire for enumVal to set.
- * @return This builder for chaining.
- */
- public Builder setEnumValValue(int value) {
- enumVal_ = value;
- bitField0_ |= 0x00000010;
- onChanged();
- return this;
- }
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return The enumVal.
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(enumVal_);
- return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
- }
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @param value The enumVal to set.
- * @return This builder for chaining.
- */
- public Builder setEnumVal(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000010;
- enumVal_ = value.getNumber();
- onChanged();
- return this;
- }
- /**
- * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
- * @return This builder for chaining.
- */
- public Builder clearEnumVal() {
- bitField0_ = (bitField0_ & ~0x00000010);
- enumVal_ = 0;
- onChanged();
- return this;
- }
-
- private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage message_;
- private com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> messageBuilder_;
- /**
- * <code>.StructMessage message = 6;</code>
- * @return Whether the message field is set.
- */
- public boolean hasMessage() {
- return ((bitField0_ & 0x00000020) != 0);
- }
- /**
- * <code>.StructMessage message = 6;</code>
- * @return The message.
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage() {
- if (messageBuilder_ == null) {
- return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
- } else {
- return messageBuilder_.getMessage();
- }
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public Builder setMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (messageBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- message_ = value;
- } else {
- messageBuilder_.setMessage(value);
- }
- bitField0_ |= 0x00000020;
- onChanged();
- return this;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public Builder setMessage(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
- if (messageBuilder_ == null) {
- message_ = builderForValue.build();
- } else {
- messageBuilder_.setMessage(builderForValue.build());
- }
- bitField0_ |= 0x00000020;
- onChanged();
- return this;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public Builder mergeMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (messageBuilder_ == null) {
- if (((bitField0_ & 0x00000020) != 0) &&
- message_ != null &&
- message_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) {
- getMessageBuilder().mergeFrom(value);
- } else {
- message_ = value;
- }
- } else {
- messageBuilder_.mergeFrom(value);
- }
- bitField0_ |= 0x00000020;
- onChanged();
- return this;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public Builder clearMessage() {
- bitField0_ = (bitField0_ & ~0x00000020);
- message_ = null;
- if (messageBuilder_ != null) {
- messageBuilder_.dispose();
- messageBuilder_ = null;
- }
- onChanged();
- return this;
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getMessageBuilder() {
- bitField0_ |= 0x00000020;
- onChanged();
- return getMessageFieldBuilder().getBuilder();
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder() {
- if (messageBuilder_ != null) {
- return messageBuilder_.getMessageOrBuilder();
- } else {
- return message_ == null ?
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
- }
- }
- /**
- * <code>.StructMessage message = 6;</code>
- */
- private com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getMessageFieldBuilder() {
- if (messageBuilder_ == null) {
- messageBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
- getMessage(),
- getParentForChildren(),
- isClean());
- message_ = null;
- }
- return messageBuilder_;
- }
-
- private long optionalInt64_ ;
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return Whether the optionalInt64 field is set.
- */
- @java.lang.Override
- public boolean hasOptionalInt64() {
- return ((bitField0_ & 0x00000040) != 0);
- }
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return The optionalInt64.
- */
- @java.lang.Override
- public long getOptionalInt64() {
- return optionalInt64_;
- }
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @param value The optionalInt64 to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalInt64(long value) {
-
- optionalInt64_ = value;
- bitField0_ |= 0x00000040;
- onChanged();
- return this;
- }
- /**
- * <code>optional int64 optional_int64 = 7;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalInt64() {
- bitField0_ = (bitField0_ & ~0x00000040);
- optionalInt64_ = 0L;
- onChanged();
- return this;
- }
-
- private int optionalInt32_ ;
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return Whether the optionalInt32 field is set.
- */
- @java.lang.Override
- public boolean hasOptionalInt32() {
- return ((bitField0_ & 0x00000080) != 0);
- }
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return The optionalInt32.
- */
- @java.lang.Override
- public int getOptionalInt32() {
- return optionalInt32_;
- }
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @param value The optionalInt32 to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalInt32(int value) {
-
- optionalInt32_ = value;
- bitField0_ |= 0x00000080;
- onChanged();
- return this;
- }
- /**
- * <code>optional int32 optional_int32 = 8;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalInt32() {
- bitField0_ = (bitField0_ & ~0x00000080);
- optionalInt32_ = 0;
- onChanged();
- return this;
- }
-
- private java.lang.Object optionalText_ = "";
- /**
- * <code>optional string optional_text = 9;</code>
- * @return Whether the optionalText field is set.
- */
- public boolean hasOptionalText() {
- return ((bitField0_ & 0x00000100) != 0);
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The optionalText.
- */
- public java.lang.String getOptionalText() {
- java.lang.Object ref = optionalText_;
- if (!(ref instanceof java.lang.String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- java.lang.String s = bs.toStringUtf8();
- optionalText_ = s;
- return s;
- } else {
- return (java.lang.String) ref;
- }
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @return The bytes for optionalText.
- */
- public com.google.protobuf.ByteString
- getOptionalTextBytes() {
- java.lang.Object ref = optionalText_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (java.lang.String) ref);
- optionalText_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @param value The optionalText to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalText(
- java.lang.String value) {
- if (value == null) { throw new NullPointerException(); }
- optionalText_ = value;
- bitField0_ |= 0x00000100;
- onChanged();
- return this;
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalText() {
- optionalText_ = getDefaultInstance().getOptionalText();
- bitField0_ = (bitField0_ & ~0x00000100);
- onChanged();
- return this;
- }
- /**
- * <code>optional string optional_text = 9;</code>
- * @param value The bytes for optionalText to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalTextBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) { throw new NullPointerException(); }
- checkByteStringIsUtf8(value);
- optionalText_ = value;
- bitField0_ |= 0x00000100;
- onChanged();
- return this;
- }
-
- private com.google.protobuf.ByteString optionalBytes_ = com.google.protobuf.ByteString.EMPTY;
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return Whether the optionalBytes field is set.
- */
- @java.lang.Override
- public boolean hasOptionalBytes() {
- return ((bitField0_ & 0x00000200) != 0);
- }
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return The optionalBytes.
- */
- @java.lang.Override
- public com.google.protobuf.ByteString getOptionalBytes() {
- return optionalBytes_;
- }
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @param value The optionalBytes to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalBytes(com.google.protobuf.ByteString value) {
- if (value == null) { throw new NullPointerException(); }
- optionalBytes_ = value;
- bitField0_ |= 0x00000200;
- onChanged();
- return this;
- }
- /**
- * <code>optional bytes optional_bytes = 10;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalBytes() {
- bitField0_ = (bitField0_ & ~0x00000200);
- optionalBytes_ = getDefaultInstance().getOptionalBytes();
- onChanged();
- return this;
- }
-
- private int optionalEnumVal_ = 0;
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return Whether the optionalEnumVal field is set.
- */
- @java.lang.Override public boolean hasOptionalEnumVal() {
- return ((bitField0_ & 0x00000400) != 0);
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The enum numeric value on the wire for optionalEnumVal.
- */
- @java.lang.Override public int getOptionalEnumValValue() {
- return optionalEnumVal_;
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @param value The enum numeric value on the wire for optionalEnumVal to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalEnumValValue(int value) {
- optionalEnumVal_ = value;
- bitField0_ |= 0x00000400;
- onChanged();
- return this;
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return The optionalEnumVal.
- */
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal() {
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(optionalEnumVal_);
- return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @param value The optionalEnumVal to set.
- * @return This builder for chaining.
- */
- public Builder setOptionalEnumVal(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum value) {
- if (value == null) {
- throw new NullPointerException();
- }
- bitField0_ |= 0x00000400;
- optionalEnumVal_ = value.getNumber();
- onChanged();
- return this;
- }
- /**
- * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
- * @return This builder for chaining.
- */
- public Builder clearOptionalEnumVal() {
- bitField0_ = (bitField0_ & ~0x00000400);
- optionalEnumVal_ = 0;
- onChanged();
- return this;
- }
-
- private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage optionalMessage_;
- private com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> optionalMessageBuilder_;
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return Whether the optionalMessage field is set.
- */
- public boolean hasOptionalMessage() {
- return ((bitField0_ & 0x00000800) != 0);
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- * @return The optionalMessage.
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage() {
- if (optionalMessageBuilder_ == null) {
- return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
- } else {
- return optionalMessageBuilder_.getMessage();
- }
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public Builder setOptionalMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (optionalMessageBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- optionalMessage_ = value;
- } else {
- optionalMessageBuilder_.setMessage(value);
- }
- bitField0_ |= 0x00000800;
- onChanged();
- return this;
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public Builder setOptionalMessage(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
- if (optionalMessageBuilder_ == null) {
- optionalMessage_ = builderForValue.build();
- } else {
- optionalMessageBuilder_.setMessage(builderForValue.build());
- }
- bitField0_ |= 0x00000800;
- onChanged();
- return this;
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public Builder mergeOptionalMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (optionalMessageBuilder_ == null) {
- if (((bitField0_ & 0x00000800) != 0) &&
- optionalMessage_ != null &&
- optionalMessage_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) {
- getOptionalMessageBuilder().mergeFrom(value);
- } else {
- optionalMessage_ = value;
- }
- } else {
- optionalMessageBuilder_.mergeFrom(value);
- }
- bitField0_ |= 0x00000800;
- onChanged();
- return this;
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public Builder clearOptionalMessage() {
- bitField0_ = (bitField0_ & ~0x00000800);
- optionalMessage_ = null;
- if (optionalMessageBuilder_ != null) {
- optionalMessageBuilder_.dispose();
- optionalMessageBuilder_ = null;
- }
- onChanged();
- return this;
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getOptionalMessageBuilder() {
- bitField0_ |= 0x00000800;
- onChanged();
- return getOptionalMessageFieldBuilder().getBuilder();
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder() {
- if (optionalMessageBuilder_ != null) {
- return optionalMessageBuilder_.getMessageOrBuilder();
- } else {
- return optionalMessage_ == null ?
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
- }
- }
- /**
- * <code>optional .StructMessage optional_message = 12;</code>
- */
- private com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getOptionalMessageFieldBuilder() {
- if (optionalMessageBuilder_ == null) {
- optionalMessageBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
- getOptionalMessage(),
- getParentForChildren(),
- isClean());
- optionalMessage_ = null;
- }
- return optionalMessageBuilder_;
- }
-
- private com.google.protobuf.Internal.LongList repeatedInt64_ = emptyLongList();
- private void ensureRepeatedInt64IsMutable() {
- if (!((bitField0_ & 0x00001000) != 0)) {
- repeatedInt64_ = mutableCopy(repeatedInt64_);
- bitField0_ |= 0x00001000;
- }
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return A list containing the repeatedInt64.
- */
- public java.util.List<java.lang.Long>
- getRepeatedInt64List() {
- return ((bitField0_ & 0x00001000) != 0) ?
- java.util.Collections.unmodifiableList(repeatedInt64_) : repeatedInt64_;
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return The count of repeatedInt64.
- */
- public int getRepeatedInt64Count() {
- return repeatedInt64_.size();
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt64 at the given index.
- */
- public long getRepeatedInt64(int index) {
- return repeatedInt64_.getLong(index);
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param index The index to set the value at.
- * @param value The repeatedInt64 to set.
- * @return This builder for chaining.
- */
- public Builder setRepeatedInt64(
- int index, long value) {
-
- ensureRepeatedInt64IsMutable();
- repeatedInt64_.setLong(index, value);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param value The repeatedInt64 to add.
- * @return This builder for chaining.
- */
- public Builder addRepeatedInt64(long value) {
-
- ensureRepeatedInt64IsMutable();
- repeatedInt64_.addLong(value);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @param values The repeatedInt64 to add.
- * @return This builder for chaining.
- */
- public Builder addAllRepeatedInt64(
- java.lang.Iterable<? extends java.lang.Long> values) {
- ensureRepeatedInt64IsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, repeatedInt64_);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int64 repeated_int64 = 13;</code>
- * @return This builder for chaining.
- */
- public Builder clearRepeatedInt64() {
- repeatedInt64_ = emptyLongList();
- bitField0_ = (bitField0_ & ~0x00001000);
- onChanged();
- return this;
- }
-
- private com.google.protobuf.Internal.IntList repeatedInt32_ = emptyIntList();
- private void ensureRepeatedInt32IsMutable() {
- if (!((bitField0_ & 0x00002000) != 0)) {
- repeatedInt32_ = mutableCopy(repeatedInt32_);
- bitField0_ |= 0x00002000;
- }
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return A list containing the repeatedInt32.
- */
- public java.util.List<java.lang.Integer>
- getRepeatedInt32List() {
- return ((bitField0_ & 0x00002000) != 0) ?
- java.util.Collections.unmodifiableList(repeatedInt32_) : repeatedInt32_;
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return The count of repeatedInt32.
- */
- public int getRepeatedInt32Count() {
- return repeatedInt32_.size();
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param index The index of the element to return.
- * @return The repeatedInt32 at the given index.
- */
- public int getRepeatedInt32(int index) {
- return repeatedInt32_.getInt(index);
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param index The index to set the value at.
- * @param value The repeatedInt32 to set.
- * @return This builder for chaining.
- */
- public Builder setRepeatedInt32(
- int index, int value) {
-
- ensureRepeatedInt32IsMutable();
- repeatedInt32_.setInt(index, value);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param value The repeatedInt32 to add.
- * @return This builder for chaining.
- */
- public Builder addRepeatedInt32(int value) {
-
- ensureRepeatedInt32IsMutable();
- repeatedInt32_.addInt(value);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @param values The repeatedInt32 to add.
- * @return This builder for chaining.
- */
- public Builder addAllRepeatedInt32(
- java.lang.Iterable<? extends java.lang.Integer> values) {
- ensureRepeatedInt32IsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, repeatedInt32_);
- onChanged();
- return this;
- }
- /**
- * <code>repeated int32 repeated_int32 = 14;</code>
- * @return This builder for chaining.
- */
- public Builder clearRepeatedInt32() {
- repeatedInt32_ = emptyIntList();
- bitField0_ = (bitField0_ & ~0x00002000);
- onChanged();
- return this;
- }
-
- private java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> repeatedMessage_ =
- java.util.Collections.emptyList();
- private void ensureRepeatedMessageIsMutable() {
- if (!((bitField0_ & 0x00004000) != 0)) {
- repeatedMessage_ = new java.util.ArrayList<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage>(repeatedMessage_);
- bitField0_ |= 0x00004000;
- }
- }
-
- private com.google.protobuf.RepeatedFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> repeatedMessageBuilder_;
-
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> getRepeatedMessageList() {
- if (repeatedMessageBuilder_ == null) {
- return java.util.Collections.unmodifiableList(repeatedMessage_);
- } else {
- return repeatedMessageBuilder_.getMessageList();
- }
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public int getRepeatedMessageCount() {
- if (repeatedMessageBuilder_ == null) {
- return repeatedMessage_.size();
- } else {
- return repeatedMessageBuilder_.getCount();
- }
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index) {
- if (repeatedMessageBuilder_ == null) {
- return repeatedMessage_.get(index);
- } else {
- return repeatedMessageBuilder_.getMessage(index);
- }
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder setRepeatedMessage(
- int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (repeatedMessageBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.set(index, value);
- onChanged();
- } else {
- repeatedMessageBuilder_.setMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder setRepeatedMessage(
- int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.set(index, builderForValue.build());
- onChanged();
- } else {
- repeatedMessageBuilder_.setMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder addRepeatedMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (repeatedMessageBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.add(value);
- onChanged();
- } else {
- repeatedMessageBuilder_.addMessage(value);
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder addRepeatedMessage(
- int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
- if (repeatedMessageBuilder_ == null) {
- if (value == null) {
- throw new NullPointerException();
- }
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.add(index, value);
- onChanged();
- } else {
- repeatedMessageBuilder_.addMessage(index, value);
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder addRepeatedMessage(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.add(builderForValue.build());
- onChanged();
- } else {
- repeatedMessageBuilder_.addMessage(builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder addRepeatedMessage(
- int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.add(index, builderForValue.build());
- onChanged();
- } else {
- repeatedMessageBuilder_.addMessage(index, builderForValue.build());
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder addAllRepeatedMessage(
- java.lang.Iterable<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> values) {
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- com.google.protobuf.AbstractMessageLite.Builder.addAll(
- values, repeatedMessage_);
- onChanged();
- } else {
- repeatedMessageBuilder_.addAllMessages(values);
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder clearRepeatedMessage() {
- if (repeatedMessageBuilder_ == null) {
- repeatedMessage_ = java.util.Collections.emptyList();
- bitField0_ = (bitField0_ & ~0x00004000);
- onChanged();
- } else {
- repeatedMessageBuilder_.clear();
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public Builder removeRepeatedMessage(int index) {
- if (repeatedMessageBuilder_ == null) {
- ensureRepeatedMessageIsMutable();
- repeatedMessage_.remove(index);
- onChanged();
- } else {
- repeatedMessageBuilder_.remove(index);
- }
- return this;
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getRepeatedMessageBuilder(
- int index) {
- return getRepeatedMessageFieldBuilder().getBuilder(index);
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
- int index) {
- if (repeatedMessageBuilder_ == null) {
- return repeatedMessage_.get(index); } else {
- return repeatedMessageBuilder_.getMessageOrBuilder(index);
- }
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getRepeatedMessageOrBuilderList() {
- if (repeatedMessageBuilder_ != null) {
- return repeatedMessageBuilder_.getMessageOrBuilderList();
- } else {
- return java.util.Collections.unmodifiableList(repeatedMessage_);
- }
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder addRepeatedMessageBuilder() {
- return getRepeatedMessageFieldBuilder().addBuilder(
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance());
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder addRepeatedMessageBuilder(
- int index) {
- return getRepeatedMessageFieldBuilder().addBuilder(
- index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance());
- }
- /**
- * <code>repeated .StructMessage repeated_message = 15;</code>
- */
- public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder>
- getRepeatedMessageBuilderList() {
- return getRepeatedMessageFieldBuilder().getBuilderList();
- }
- private com.google.protobuf.RepeatedFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
- getRepeatedMessageFieldBuilder() {
- if (repeatedMessageBuilder_ == null) {
- repeatedMessageBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
- com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
- repeatedMessage_,
- ((bitField0_ & 0x00004000) != 0),
- getParentForChildren(),
- isClean());
- repeatedMessage_ = null;
- }
- return repeatedMessageBuilder_;
- }
- @java.lang.Override
- public final Builder setUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.setUnknownFields(unknownFields);
- }
-
- @java.lang.Override
- public final Builder mergeUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.mergeUnknownFields(unknownFields);
- }
-
-
- // @@protoc_insertion_point(builder_scope:Proto3Types)
- }
-
- // @@protoc_insertion_point(class_scope:Proto3Types)
- private static final com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types DEFAULT_INSTANCE;
- static {
- DEFAULT_INSTANCE = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types();
- }
-
- public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstance() {
- return DEFAULT_INSTANCE;
- }
-
- private static final com.google.protobuf.Parser<Proto3Types>
- PARSER = new com.google.protobuf.AbstractParser<Proto3Types>() {
- @java.lang.Override
- public Proto3Types parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- Builder builder = newBuilder();
- try {
- builder.mergeFrom(input, extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(builder.buildPartial());
- } catch (com.google.protobuf.UninitializedMessageException e) {
- throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(e)
- .setUnfinishedMessage(builder.buildPartial());
- }
- return builder.buildPartial();
- }
- };
-
- public static com.google.protobuf.Parser<Proto3Types> parser() {
- return PARSER;
- }
-
- @java.lang.Override
- public com.google.protobuf.Parser<Proto3Types> getParserForType() {
- return PARSER;
- }
-
- @java.lang.Override
- public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
- }
-
- private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_StructMessage_descriptor;
- private static final
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internal_static_StructMessage_fieldAccessorTable;
- private static final com.google.protobuf.Descriptors.Descriptor
- internal_static_Proto3Types_descriptor;
- private static final
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internal_static_Proto3Types_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\022proto3_types.proto\"\233\001\n\rStructMessage\022\n" +
- "\n\002id\030\001 \001(\003\022\014\n\004name\030\002 \001(\t\022\013\n\003age\030\003 \001(\005\022\r\n" +
- "\005score\030\004 \001(\001\022\030\n\013optional_id\030\005 \001(\003H\000\210\001\001\022\031" +
- "\n\014optional_age\030\006 \001(\005H\001\210\001\001B\016\n\014_optional_i" +
- "dB\017\n\r_optional_age\"\361\004\n\013Proto3Types\022\r\n\005in" +
- "t64\030\001 \001(\003\022\r\n\005int32\030\002 \001(\005\022\014\n\004text\030\003 \001(\t\022\r" +
- "\n\005bytes\030\004 \001(\014\022)\n\010enum_val\030\005 \001(\0162\027.Proto3" +
- "Types.NestedEnum\022\037\n\007message\030\006 \001(\0132\016.Stru" +
- "ctMessage\022\033\n\016optional_int64\030\007 \001(\003H\000\210\001\001\022\033" +
- "\n\016optional_int32\030\010 \001(\005H\001\210\001\001\022\032\n\roptional_" +
- "text\030\t \001(\tH\002\210\001\001\022\033\n\016optional_bytes\030\n \001(\014H" +
- "\003\210\001\001\0227\n\021optional_enum_val\030\013 \001(\0162\027.Proto3" +
- "Types.NestedEnumH\004\210\001\001\022-\n\020optional_messag" +
- "e\030\014 \001(\0132\016.StructMessageH\005\210\001\001\022\026\n\016repeated" +
- "_int64\030\r \003(\003\022\026\n\016repeated_int32\030\016 \003(\005\022(\n\020" +
- "repeated_message\030\017 \003(\0132\016.StructMessage\"0" +
- "\n\nNestedEnum\022\013\n\007NOTHING\020\000\022\t\n\005FIRST\020\001\022\n\n\006" +
- "SECOND\020\002B\021\n\017_optional_int64B\021\n\017_optional" +
- "_int32B\020\n\016_optional_textB\021\n\017_optional_by" +
- "tesB\024\n\022_optional_enum_valB\023\n\021_optional_m" +
- "essageB8\n#com.geedgenetworks.formats.pro" +
- "tobufB\021Proto3TypesProtosb\006proto3"
- };
- descriptor = com.google.protobuf.Descriptors.FileDescriptor
- .internalBuildGeneratedFileFrom(descriptorData,
- new com.google.protobuf.Descriptors.FileDescriptor[] {
- });
- internal_static_StructMessage_descriptor =
- getDescriptor().getMessageTypes().get(0);
- internal_static_StructMessage_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
- internal_static_StructMessage_descriptor,
- new java.lang.String[] { "Id", "Name", "Age", "Score", "OptionalId", "OptionalAge", "OptionalId", "OptionalAge", });
- internal_static_Proto3Types_descriptor =
- getDescriptor().getMessageTypes().get(1);
- internal_static_Proto3Types_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
- internal_static_Proto3Types_descriptor,
- new java.lang.String[] { "Int64", "Int32", "Text", "Bytes", "EnumVal", "Message", "OptionalInt64", "OptionalInt32", "OptionalText", "OptionalBytes", "OptionalEnumVal", "OptionalMessage", "RepeatedInt64", "RepeatedInt32", "RepeatedMessage", "OptionalInt64", "OptionalInt32", "OptionalText", "OptionalBytes", "OptionalEnumVal", "OptionalMessage", });
- }
-
- // @@protoc_insertion_point(outer_class_scope)
-}
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: proto3_types.proto
+
+package com.geedgenetworks.formats.protobuf;
+
+public final class Proto3TypesProtos {
+ private Proto3TypesProtos() {}
+ public static void registerAllExtensions(
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite registry) {
+ }
+
+ public static void registerAllExtensions(
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ public interface StructMessageOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:StructMessage)
+ com.geedgenetworks.shaded.com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>int64 id = 1;</code>
+ * @return The id.
+ */
+ long getId();
+
+ /**
+ * <code>string name = 2;</code>
+ * @return The name.
+ */
+ java.lang.String getName();
+ /**
+ * <code>string name = 2;</code>
+ * @return The bytes for name.
+ */
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getNameBytes();
+
+ /**
+ * <code>int32 age = 3;</code>
+ * @return The age.
+ */
+ int getAge();
+
+ /**
+ * <code>double score = 4;</code>
+ * @return The score.
+ */
+ double getScore();
+
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return Whether the optionalId field is set.
+ */
+ boolean hasOptionalId();
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return The optionalId.
+ */
+ long getOptionalId();
+
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return Whether the optionalAge field is set.
+ */
+ boolean hasOptionalAge();
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return The optionalAge.
+ */
+ int getOptionalAge();
+ }
+ /**
+ * Protobuf type {@code StructMessage}
+ */
+ public static final class StructMessage extends
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:StructMessage)
+ StructMessageOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use StructMessage.newBuilder() to construct.
+ private StructMessage(com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
+ super(builder);
+ }
+ private StructMessage() {
+ name_ = "";
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new StructMessage();
+ }
+
+ public static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder.class);
+ }
+
+ private int bitField0_;
+ public static final int ID_FIELD_NUMBER = 1;
+ private long id_ = 0L;
+ /**
+ * <code>int64 id = 1;</code>
+ * @return The id.
+ */
+ @java.lang.Override
+ public long getId() {
+ return id_;
+ }
+
+ public static final int NAME_FIELD_NUMBER = 2;
+ @SuppressWarnings("serial")
+ private volatile java.lang.Object name_ = "";
+ /**
+ * <code>string name = 2;</code>
+ * @return The name.
+ */
+ @java.lang.Override
+ public java.lang.String getName() {
+ java.lang.Object ref = name_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ name_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>string name = 2;</code>
+ * @return The bytes for name.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getNameBytes() {
+ java.lang.Object ref = name_;
+ if (ref instanceof java.lang.String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ name_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int AGE_FIELD_NUMBER = 3;
+ private int age_ = 0;
+ /**
+ * <code>int32 age = 3;</code>
+ * @return The age.
+ */
+ @java.lang.Override
+ public int getAge() {
+ return age_;
+ }
+
+ public static final int SCORE_FIELD_NUMBER = 4;
+ private double score_ = 0D;
+ /**
+ * <code>double score = 4;</code>
+ * @return The score.
+ */
+ @java.lang.Override
+ public double getScore() {
+ return score_;
+ }
+
+ public static final int OPTIONAL_ID_FIELD_NUMBER = 5;
+ private long optionalId_ = 0L;
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return Whether the optionalId field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalId() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return The optionalId.
+ */
+ @java.lang.Override
+ public long getOptionalId() {
+ return optionalId_;
+ }
+
+ public static final int OPTIONAL_AGE_FIELD_NUMBER = 6;
+ private int optionalAge_ = 0;
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return Whether the optionalAge field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalAge() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return The optionalAge.
+ */
+ @java.lang.Override
+ public int getOptionalAge() {
+ return optionalAge_;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (id_ != 0L) {
+ output.writeInt64(1, id_);
+ }
+ if (!com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_);
+ }
+ if (age_ != 0) {
+ output.writeInt32(3, age_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(score_) != 0) {
+ output.writeDouble(4, score_);
+ }
+ if (((bitField0_ & 0x00000001) != 0)) {
+ output.writeInt64(5, optionalId_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ output.writeInt32(6, optionalAge_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (id_ != 0L) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt64Size(1, id_);
+ }
+ if (!com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_);
+ }
+ if (age_ != 0) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32Size(3, age_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(score_) != 0) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeDoubleSize(4, score_);
+ }
+ if (((bitField0_ & 0x00000001) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt64Size(5, optionalId_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32Size(6, optionalAge_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage)) {
+ return super.equals(obj);
+ }
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage other = (com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage) obj;
+
+ if (getId()
+ != other.getId()) return false;
+ if (!getName()
+ .equals(other.getName())) return false;
+ if (getAge()
+ != other.getAge()) return false;
+ if (java.lang.Double.doubleToLongBits(getScore())
+ != java.lang.Double.doubleToLongBits(
+ other.getScore())) return false;
+ if (hasOptionalId() != other.hasOptionalId()) return false;
+ if (hasOptionalId()) {
+ if (getOptionalId()
+ != other.getOptionalId()) return false;
+ }
+ if (hasOptionalAge() != other.hasOptionalAge()) return false;
+ if (hasOptionalAge()) {
+ if (getOptionalAge()
+ != other.getOptionalAge()) return false;
+ }
+ if (!getUnknownFields().equals(other.getUnknownFields())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + ID_FIELD_NUMBER;
+ hash = (53 * hash) + com.geedgenetworks.shaded.com.google.protobuf.Internal.hashLong(
+ getId());
+ hash = (37 * hash) + NAME_FIELD_NUMBER;
+ hash = (53 * hash) + getName().hashCode();
+ hash = (37 * hash) + AGE_FIELD_NUMBER;
+ hash = (53 * hash) + getAge();
+ hash = (37 * hash) + SCORE_FIELD_NUMBER;
+ hash = (53 * hash) + com.geedgenetworks.shaded.com.google.protobuf.Internal.hashLong(
+ java.lang.Double.doubleToLongBits(getScore()));
+ if (hasOptionalId()) {
+ hash = (37 * hash) + OPTIONAL_ID_FIELD_NUMBER;
+ hash = (53 * hash) + com.geedgenetworks.shaded.com.google.protobuf.Internal.hashLong(
+ getOptionalId());
+ }
+ if (hasOptionalAge()) {
+ hash = (37 * hash) + OPTIONAL_AGE_FIELD_NUMBER;
+ hash = (53 * hash) + getOptionalAge();
+ }
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ java.nio.ByteBuffer data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(byte[] data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ byte[] data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ java.io.InputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseDelimitedFrom(
+ java.io.InputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code StructMessage}
+ */
+ public static final class Builder extends
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:StructMessage)
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder {
+ public static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder.class);
+ }
+
+ // Construct using com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.newBuilder()
+ private Builder() {
+
+ }
+
+ private Builder(
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ bitField0_ = 0;
+ id_ = 0L;
+ name_ = "";
+ age_ = 0;
+ score_ = 0D;
+ optionalId_ = 0L;
+ optionalAge_ = 0;
+ return this;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_StructMessage_descriptor;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstanceForType() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage build() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage buildPartial() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage(this);
+ if (bitField0_ != 0) { buildPartial0(result); }
+ onBuilt();
+ return result;
+ }
+
+ private void buildPartial0(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage result) {
+ int from_bitField0_ = bitField0_;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.id_ = id_;
+ }
+ if (((from_bitField0_ & 0x00000002) != 0)) {
+ result.name_ = name_;
+ }
+ if (((from_bitField0_ & 0x00000004) != 0)) {
+ result.age_ = age_;
+ }
+ if (((from_bitField0_ & 0x00000008) != 0)) {
+ result.score_ = score_;
+ }
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000010) != 0)) {
+ result.optionalId_ = optionalId_;
+ to_bitField0_ |= 0x00000001;
+ }
+ if (((from_bitField0_ & 0x00000020) != 0)) {
+ result.optionalAge_ = optionalAge_;
+ to_bitField0_ |= 0x00000002;
+ }
+ result.bitField0_ |= to_bitField0_;
+ }
+
+ @java.lang.Override
+ public Builder clone() {
+ return super.clone();
+ }
+ @java.lang.Override
+ public Builder setField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.setField(field, value);
+ }
+ @java.lang.Override
+ public Builder clearField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return super.clearField(field);
+ }
+ @java.lang.Override
+ public Builder clearOneof(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return super.clearOneof(oneof);
+ }
+ @java.lang.Override
+ public Builder setRepeatedField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, java.lang.Object value) {
+ return super.setRepeatedField(field, index, value);
+ }
+ @java.lang.Override
+ public Builder addRepeatedField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.addRepeatedField(field, value);
+ }
+ @java.lang.Override
+ public Builder mergeFrom(com.geedgenetworks.shaded.com.google.protobuf.Message other) {
+ if (other instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage) {
+ return mergeFrom((com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage other) {
+ if (other == com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) return this;
+ if (other.getId() != 0L) {
+ setId(other.getId());
+ }
+ if (!other.getName().isEmpty()) {
+ name_ = other.name_;
+ bitField0_ |= 0x00000002;
+ onChanged();
+ }
+ if (other.getAge() != 0) {
+ setAge(other.getAge());
+ }
+ if (other.getScore() != 0D) {
+ setScore(other.getScore());
+ }
+ if (other.hasOptionalId()) {
+ setOptionalId(other.getOptionalId());
+ }
+ if (other.hasOptionalAge()) {
+ setOptionalAge(other.getOptionalAge());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 8: {
+ id_ = input.readInt64();
+ bitField0_ |= 0x00000001;
+ break;
+ } // case 8
+ case 18: {
+ name_ = input.readStringRequireUtf8();
+ bitField0_ |= 0x00000002;
+ break;
+ } // case 18
+ case 24: {
+ age_ = input.readInt32();
+ bitField0_ |= 0x00000004;
+ break;
+ } // case 24
+ case 33: {
+ score_ = input.readDouble();
+ bitField0_ |= 0x00000008;
+ break;
+ } // case 33
+ case 40: {
+ optionalId_ = input.readInt64();
+ bitField0_ |= 0x00000010;
+ break;
+ } // case 40
+ case 48: {
+ optionalAge_ = input.readInt32();
+ bitField0_ |= 0x00000020;
+ break;
+ } // case 48
+ default: {
+ if (!super.parseUnknownField(input, extensionRegistry, tag)) {
+ done = true; // was an endgroup tag
+ }
+ break;
+ } // default:
+ } // switch (tag)
+ } // while (!done)
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ } finally {
+ onChanged();
+ } // finally
+ return this;
+ }
+ private int bitField0_;
+
+ private long id_ ;
+ /**
+ * <code>int64 id = 1;</code>
+ * @return The id.
+ */
+ @java.lang.Override
+ public long getId() {
+ return id_;
+ }
+ /**
+ * <code>int64 id = 1;</code>
+ * @param value The id to set.
+ * @return This builder for chaining.
+ */
+ public Builder setId(long value) {
+
+ id_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>int64 id = 1;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearId() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ id_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object name_ = "";
+ /**
+ * <code>string name = 2;</code>
+ * @return The name.
+ */
+ public java.lang.String getName() {
+ java.lang.Object ref = name_;
+ if (!(ref instanceof java.lang.String)) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ name_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>string name = 2;</code>
+ * @return The bytes for name.
+ */
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getNameBytes() {
+ java.lang.Object ref = name_;
+ if (ref instanceof String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ name_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>string name = 2;</code>
+ * @param value The name to set.
+ * @return This builder for chaining.
+ */
+ public Builder setName(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ name_ = value;
+ bitField0_ |= 0x00000002;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string name = 2;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearName() {
+ name_ = getDefaultInstance().getName();
+ bitField0_ = (bitField0_ & ~0x00000002);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string name = 2;</code>
+ * @param value The bytes for name to set.
+ * @return This builder for chaining.
+ */
+ public Builder setNameBytes(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ name_ = value;
+ bitField0_ |= 0x00000002;
+ onChanged();
+ return this;
+ }
+
+ private int age_ ;
+ /**
+ * <code>int32 age = 3;</code>
+ * @return The age.
+ */
+ @java.lang.Override
+ public int getAge() {
+ return age_;
+ }
+ /**
+ * <code>int32 age = 3;</code>
+ * @param value The age to set.
+ * @return This builder for chaining.
+ */
+ public Builder setAge(int value) {
+
+ age_ = value;
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>int32 age = 3;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearAge() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ age_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private double score_ ;
+ /**
+ * <code>double score = 4;</code>
+ * @return The score.
+ */
+ @java.lang.Override
+ public double getScore() {
+ return score_;
+ }
+ /**
+ * <code>double score = 4;</code>
+ * @param value The score to set.
+ * @return This builder for chaining.
+ */
+ public Builder setScore(double value) {
+
+ score_ = value;
+ bitField0_ |= 0x00000008;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>double score = 4;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearScore() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ score_ = 0D;
+ onChanged();
+ return this;
+ }
+
+ private long optionalId_ ;
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return Whether the optionalId field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalId() {
+ return ((bitField0_ & 0x00000010) != 0);
+ }
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return The optionalId.
+ */
+ @java.lang.Override
+ public long getOptionalId() {
+ return optionalId_;
+ }
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @param value The optionalId to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalId(long value) {
+
+ optionalId_ = value;
+ bitField0_ |= 0x00000010;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int64 optional_id = 5;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalId() {
+ bitField0_ = (bitField0_ & ~0x00000010);
+ optionalId_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private int optionalAge_ ;
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return Whether the optionalAge field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalAge() {
+ return ((bitField0_ & 0x00000020) != 0);
+ }
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return The optionalAge.
+ */
+ @java.lang.Override
+ public int getOptionalAge() {
+ return optionalAge_;
+ }
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @param value The optionalAge to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalAge(int value) {
+
+ optionalAge_ = value;
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 optional_age = 6;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalAge() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ optionalAge_ = 0;
+ onChanged();
+ return this;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.geedgenetworks.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.geedgenetworks.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:StructMessage)
+ }
+
+ // @@protoc_insertion_point(class_scope:StructMessage)
+ private static final com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage();
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.geedgenetworks.shaded.com.google.protobuf.Parser<StructMessage>
+ PARSER = new com.geedgenetworks.shaded.com.google.protobuf.AbstractParser<StructMessage>() {
+ @java.lang.Override
+ public StructMessage parsePartialFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ Builder builder = newBuilder();
+ try {
+ builder.mergeFrom(input, extensionRegistry);
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(builder.buildPartial());
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.UninitializedMessageException e) {
+ throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
+ } catch (java.io.IOException e) {
+ throw new com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException(e)
+ .setUnfinishedMessage(builder.buildPartial());
+ }
+ return builder.buildPartial();
+ }
+ };
+
+ public static com.geedgenetworks.shaded.com.google.protobuf.Parser<StructMessage> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.Parser<StructMessage> getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ public interface Proto3TypesOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:Proto3Types)
+ com.geedgenetworks.shaded.com.google.protobuf.MessageOrBuilder {
+
+ /**
+ * <code>int64 int64 = 1;</code>
+ * @return The int64.
+ */
+ long getInt64();
+
+ /**
+ * <code>int32 int32 = 2;</code>
+ * @return The int32.
+ */
+ int getInt32();
+
+ /**
+ * <code>string text = 3;</code>
+ * @return The text.
+ */
+ java.lang.String getText();
+ /**
+ * <code>string text = 3;</code>
+ * @return The bytes for text.
+ */
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getTextBytes();
+
+ /**
+ * <code>bytes bytes = 4;</code>
+ * @return The bytes.
+ */
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString getBytes();
+
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enum numeric value on the wire for enumVal.
+ */
+ int getEnumValValue();
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enumVal.
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal();
+
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return Whether the message field is set.
+ */
+ boolean hasMessage();
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return The message.
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage();
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder();
+
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return Whether the optionalInt64 field is set.
+ */
+ boolean hasOptionalInt64();
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return The optionalInt64.
+ */
+ long getOptionalInt64();
+
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return Whether the optionalInt32 field is set.
+ */
+ boolean hasOptionalInt32();
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return The optionalInt32.
+ */
+ int getOptionalInt32();
+
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return Whether the optionalText field is set.
+ */
+ boolean hasOptionalText();
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The optionalText.
+ */
+ java.lang.String getOptionalText();
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The bytes for optionalText.
+ */
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getOptionalTextBytes();
+
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return Whether the optionalBytes field is set.
+ */
+ boolean hasOptionalBytes();
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return The optionalBytes.
+ */
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString getOptionalBytes();
+
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return Whether the optionalEnumVal field is set.
+ */
+ boolean hasOptionalEnumVal();
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The enum numeric value on the wire for optionalEnumVal.
+ */
+ int getOptionalEnumValValue();
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The optionalEnumVal.
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal();
+
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return Whether the optionalMessage field is set.
+ */
+ boolean hasOptionalMessage();
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return The optionalMessage.
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage();
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder();
+
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return A list containing the repeatedInt64.
+ */
+ java.util.List<java.lang.Long> getRepeatedInt64List();
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return The count of repeatedInt64.
+ */
+ int getRepeatedInt64Count();
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt64 at the given index.
+ */
+ long getRepeatedInt64(int index);
+
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return A list containing the repeatedInt32.
+ */
+ java.util.List<java.lang.Integer> getRepeatedInt32List();
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return The count of repeatedInt32.
+ */
+ int getRepeatedInt32Count();
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt32 at the given index.
+ */
+ int getRepeatedInt32(int index);
+
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage>
+ getRepeatedMessageList();
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index);
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ int getRepeatedMessageCount();
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getRepeatedMessageOrBuilderList();
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
+ int index);
+ }
+ /**
+ * Protobuf type {@code Proto3Types}
+ */
+ public static final class Proto3Types extends
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3 implements
+ // @@protoc_insertion_point(message_implements:Proto3Types)
+ Proto3TypesOrBuilder {
+ private static final long serialVersionUID = 0L;
+ // Use Proto3Types.newBuilder() to construct.
+ private Proto3Types(com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
+ super(builder);
+ }
+ private Proto3Types() {
+ text_ = "";
+ bytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ enumVal_ = 0;
+ optionalText_ = "";
+ optionalBytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ optionalEnumVal_ = 0;
+ repeatedInt64_ = emptyLongList();
+ repeatedInt32_ = emptyIntList();
+ repeatedMessage_ = java.util.Collections.emptyList();
+ }
+
+ @java.lang.Override
+ @SuppressWarnings({"unused"})
+ protected java.lang.Object newInstance(
+ UnusedPrivateParameter unused) {
+ return new Proto3Types();
+ }
+
+ public static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.Builder.class);
+ }
+
+ /**
+ * Protobuf enum {@code Proto3Types.NestedEnum}
+ */
+ public enum NestedEnum
+ implements com.geedgenetworks.shaded.com.google.protobuf.ProtocolMessageEnum {
+ /**
+ * <code>NOTHING = 0;</code>
+ */
+ NOTHING(0),
+ /**
+ * <code>FIRST = 1;</code>
+ */
+ FIRST(1),
+ /**
+ * <code>SECOND = 2;</code>
+ */
+ SECOND(2),
+ UNRECOGNIZED(-1),
+ ;
+
+ /**
+ * <code>NOTHING = 0;</code>
+ */
+ public static final int NOTHING_VALUE = 0;
+ /**
+ * <code>FIRST = 1;</code>
+ */
+ public static final int FIRST_VALUE = 1;
+ /**
+ * <code>SECOND = 2;</code>
+ */
+ public static final int SECOND_VALUE = 2;
+
+
+ public final int getNumber() {
+ if (this == UNRECOGNIZED) {
+ throw new java.lang.IllegalArgumentException(
+ "Can't get the number of an unknown enum value.");
+ }
+ return value;
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ * @deprecated Use {@link #forNumber(int)} instead.
+ */
+ @java.lang.Deprecated
+ public static NestedEnum valueOf(int value) {
+ return forNumber(value);
+ }
+
+ /**
+ * @param value The numeric wire value of the corresponding enum entry.
+ * @return The enum associated with the given numeric wire value.
+ */
+ public static NestedEnum forNumber(int value) {
+ switch (value) {
+ case 0: return NOTHING;
+ case 1: return FIRST;
+ case 2: return SECOND;
+ default: return null;
+ }
+ }
+
+ public static com.geedgenetworks.shaded.com.google.protobuf.Internal.EnumLiteMap<NestedEnum>
+ internalGetValueMap() {
+ return internalValueMap;
+ }
+ private static final com.geedgenetworks.shaded.com.google.protobuf.Internal.EnumLiteMap<
+ NestedEnum> internalValueMap =
+ new com.geedgenetworks.shaded.com.google.protobuf.Internal.EnumLiteMap<NestedEnum>() {
+ public NestedEnum findValueByNumber(int number) {
+ return NestedEnum.forNumber(number);
+ }
+ };
+
+ public final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor
+ getValueDescriptor() {
+ if (this == UNRECOGNIZED) {
+ throw new java.lang.IllegalStateException(
+ "Can't get the descriptor of an unrecognized enum value.");
+ }
+ return getDescriptor().getValues().get(ordinal());
+ }
+ public final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+ public static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.EnumDescriptor
+ getDescriptor() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDescriptor().getEnumTypes().get(0);
+ }
+
+ private static final NestedEnum[] VALUES = values();
+
+ public static NestedEnum valueOf(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
+ if (desc.getType() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "EnumValueDescriptor is not for this type.");
+ }
+ if (desc.getIndex() == -1) {
+ return UNRECOGNIZED;
+ }
+ return VALUES[desc.getIndex()];
+ }
+
+ private final int value;
+
+ private NestedEnum(int value) {
+ this.value = value;
+ }
+
+ // @@protoc_insertion_point(enum_scope:Proto3Types.NestedEnum)
+ }
+
+ private int bitField0_;
+ public static final int INT64_FIELD_NUMBER = 1;
+ private long int64_ = 0L;
+ /**
+ * <code>int64 int64 = 1;</code>
+ * @return The int64.
+ */
+ @java.lang.Override
+ public long getInt64() {
+ return int64_;
+ }
+
+ public static final int INT32_FIELD_NUMBER = 2;
+ private int int32_ = 0;
+ /**
+ * <code>int32 int32 = 2;</code>
+ * @return The int32.
+ */
+ @java.lang.Override
+ public int getInt32() {
+ return int32_;
+ }
+
+ public static final int TEXT_FIELD_NUMBER = 3;
+ @SuppressWarnings("serial")
+ private volatile java.lang.Object text_ = "";
+ /**
+ * <code>string text = 3;</code>
+ * @return The text.
+ */
+ @java.lang.Override
+ public java.lang.String getText() {
+ java.lang.Object ref = text_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ text_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>string text = 3;</code>
+ * @return The bytes for text.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getTextBytes() {
+ java.lang.Object ref = text_;
+ if (ref instanceof java.lang.String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ text_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int BYTES_FIELD_NUMBER = 4;
+ private com.geedgenetworks.shaded.com.google.protobuf.ByteString bytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>bytes bytes = 4;</code>
+ * @return The bytes.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString getBytes() {
+ return bytes_;
+ }
+
+ public static final int ENUM_VAL_FIELD_NUMBER = 5;
+ private int enumVal_ = 0;
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enum numeric value on the wire for enumVal.
+ */
+ @java.lang.Override public int getEnumValValue() {
+ return enumVal_;
+ }
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enumVal.
+ */
+ @java.lang.Override public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(enumVal_);
+ return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
+ }
+
+ public static final int MESSAGE_FIELD_NUMBER = 6;
+ private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage message_;
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return Whether the message field is set.
+ */
+ @java.lang.Override
+ public boolean hasMessage() {
+ return message_ != null;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return The message.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage() {
+ return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder() {
+ return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
+ }
+
+ public static final int OPTIONAL_INT64_FIELD_NUMBER = 7;
+ private long optionalInt64_ = 0L;
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return Whether the optionalInt64 field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalInt64() {
+ return ((bitField0_ & 0x00000001) != 0);
+ }
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return The optionalInt64.
+ */
+ @java.lang.Override
+ public long getOptionalInt64() {
+ return optionalInt64_;
+ }
+
+ public static final int OPTIONAL_INT32_FIELD_NUMBER = 8;
+ private int optionalInt32_ = 0;
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return Whether the optionalInt32 field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalInt32() {
+ return ((bitField0_ & 0x00000002) != 0);
+ }
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return The optionalInt32.
+ */
+ @java.lang.Override
+ public int getOptionalInt32() {
+ return optionalInt32_;
+ }
+
+ public static final int OPTIONAL_TEXT_FIELD_NUMBER = 9;
+ @SuppressWarnings("serial")
+ private volatile java.lang.Object optionalText_ = "";
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return Whether the optionalText field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalText() {
+ return ((bitField0_ & 0x00000004) != 0);
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The optionalText.
+ */
+ @java.lang.Override
+ public java.lang.String getOptionalText() {
+ java.lang.Object ref = optionalText_;
+ if (ref instanceof java.lang.String) {
+ return (java.lang.String) ref;
+ } else {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ optionalText_ = s;
+ return s;
+ }
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The bytes for optionalText.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getOptionalTextBytes() {
+ java.lang.Object ref = optionalText_;
+ if (ref instanceof java.lang.String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ optionalText_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ public static final int OPTIONAL_BYTES_FIELD_NUMBER = 10;
+ private com.geedgenetworks.shaded.com.google.protobuf.ByteString optionalBytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return Whether the optionalBytes field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalBytes() {
+ return ((bitField0_ & 0x00000008) != 0);
+ }
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return The optionalBytes.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString getOptionalBytes() {
+ return optionalBytes_;
+ }
+
+ public static final int OPTIONAL_ENUM_VAL_FIELD_NUMBER = 11;
+ private int optionalEnumVal_ = 0;
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return Whether the optionalEnumVal field is set.
+ */
+ @java.lang.Override public boolean hasOptionalEnumVal() {
+ return ((bitField0_ & 0x00000010) != 0);
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The enum numeric value on the wire for optionalEnumVal.
+ */
+ @java.lang.Override public int getOptionalEnumValValue() {
+ return optionalEnumVal_;
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The optionalEnumVal.
+ */
+ @java.lang.Override public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(optionalEnumVal_);
+ return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
+ }
+
+ public static final int OPTIONAL_MESSAGE_FIELD_NUMBER = 12;
+ private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage optionalMessage_;
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return Whether the optionalMessage field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalMessage() {
+ return ((bitField0_ & 0x00000020) != 0);
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return The optionalMessage.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage() {
+ return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder() {
+ return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
+ }
+
+ public static final int REPEATED_INT64_FIELD_NUMBER = 13;
+ @SuppressWarnings("serial")
+ private com.geedgenetworks.shaded.com.google.protobuf.Internal.LongList repeatedInt64_;
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return A list containing the repeatedInt64.
+ */
+ @java.lang.Override
+ public java.util.List<java.lang.Long>
+ getRepeatedInt64List() {
+ return repeatedInt64_;
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return The count of repeatedInt64.
+ */
+ public int getRepeatedInt64Count() {
+ return repeatedInt64_.size();
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt64 at the given index.
+ */
+ public long getRepeatedInt64(int index) {
+ return repeatedInt64_.getLong(index);
+ }
+ private int repeatedInt64MemoizedSerializedSize = -1;
+
+ public static final int REPEATED_INT32_FIELD_NUMBER = 14;
+ @SuppressWarnings("serial")
+ private com.geedgenetworks.shaded.com.google.protobuf.Internal.IntList repeatedInt32_;
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return A list containing the repeatedInt32.
+ */
+ @java.lang.Override
+ public java.util.List<java.lang.Integer>
+ getRepeatedInt32List() {
+ return repeatedInt32_;
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return The count of repeatedInt32.
+ */
+ public int getRepeatedInt32Count() {
+ return repeatedInt32_.size();
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt32 at the given index.
+ */
+ public int getRepeatedInt32(int index) {
+ return repeatedInt32_.getInt(index);
+ }
+ private int repeatedInt32MemoizedSerializedSize = -1;
+
+ public static final int REPEATED_MESSAGE_FIELD_NUMBER = 15;
+ @SuppressWarnings("serial")
+ private java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> repeatedMessage_;
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ @java.lang.Override
+ public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> getRepeatedMessageList() {
+ return repeatedMessage_;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ @java.lang.Override
+ public java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getRepeatedMessageOrBuilderList() {
+ return repeatedMessage_;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ @java.lang.Override
+ public int getRepeatedMessageCount() {
+ return repeatedMessage_.size();
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index) {
+ return repeatedMessage_.get(index);
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
+ int index) {
+ return repeatedMessage_.get(index);
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (int64_ != 0L) {
+ output.writeInt64(1, int64_);
+ }
+ if (int32_ != 0) {
+ output.writeInt32(2, int32_);
+ }
+ if (!com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.isStringEmpty(text_)) {
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.writeString(output, 3, text_);
+ }
+ if (!bytes_.isEmpty()) {
+ output.writeBytes(4, bytes_);
+ }
+ if (enumVal_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.NOTHING.getNumber()) {
+ output.writeEnum(5, enumVal_);
+ }
+ if (message_ != null) {
+ output.writeMessage(6, getMessage());
+ }
+ if (((bitField0_ & 0x00000001) != 0)) {
+ output.writeInt64(7, optionalInt64_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ output.writeInt32(8, optionalInt32_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.writeString(output, 9, optionalText_);
+ }
+ if (((bitField0_ & 0x00000008) != 0)) {
+ output.writeBytes(10, optionalBytes_);
+ }
+ if (((bitField0_ & 0x00000010) != 0)) {
+ output.writeEnum(11, optionalEnumVal_);
+ }
+ if (((bitField0_ & 0x00000020) != 0)) {
+ output.writeMessage(12, getOptionalMessage());
+ }
+ if (getRepeatedInt64List().size() > 0) {
+ output.writeUInt32NoTag(106);
+ output.writeUInt32NoTag(repeatedInt64MemoizedSerializedSize);
+ }
+ for (int i = 0; i < repeatedInt64_.size(); i++) {
+ output.writeInt64NoTag(repeatedInt64_.getLong(i));
+ }
+ if (getRepeatedInt32List().size() > 0) {
+ output.writeUInt32NoTag(114);
+ output.writeUInt32NoTag(repeatedInt32MemoizedSerializedSize);
+ }
+ for (int i = 0; i < repeatedInt32_.size(); i++) {
+ output.writeInt32NoTag(repeatedInt32_.getInt(i));
+ }
+ for (int i = 0; i < repeatedMessage_.size(); i++) {
+ output.writeMessage(15, repeatedMessage_.get(i));
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (int64_ != 0L) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt64Size(1, int64_);
+ }
+ if (int32_ != 0) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32Size(2, int32_);
+ }
+ if (!com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.isStringEmpty(text_)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.computeStringSize(3, text_);
+ }
+ if (!bytes_.isEmpty()) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeBytesSize(4, bytes_);
+ }
+ if (enumVal_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.NOTHING.getNumber()) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeEnumSize(5, enumVal_);
+ }
+ if (message_ != null) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeMessageSize(6, getMessage());
+ }
+ if (((bitField0_ & 0x00000001) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt64Size(7, optionalInt64_);
+ }
+ if (((bitField0_ & 0x00000002) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32Size(8, optionalInt32_);
+ }
+ if (((bitField0_ & 0x00000004) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.computeStringSize(9, optionalText_);
+ }
+ if (((bitField0_ & 0x00000008) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeBytesSize(10, optionalBytes_);
+ }
+ if (((bitField0_ & 0x00000010) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeEnumSize(11, optionalEnumVal_);
+ }
+ if (((bitField0_ & 0x00000020) != 0)) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeMessageSize(12, getOptionalMessage());
+ }
+ {
+ int dataSize = 0;
+ for (int i = 0; i < repeatedInt64_.size(); i++) {
+ dataSize += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt64SizeNoTag(repeatedInt64_.getLong(i));
+ }
+ size += dataSize;
+ if (!getRepeatedInt64List().isEmpty()) {
+ size += 1;
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(dataSize);
+ }
+ repeatedInt64MemoizedSerializedSize = dataSize;
+ }
+ {
+ int dataSize = 0;
+ for (int i = 0; i < repeatedInt32_.size(); i++) {
+ dataSize += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(repeatedInt32_.getInt(i));
+ }
+ size += dataSize;
+ if (!getRepeatedInt32List().isEmpty()) {
+ size += 1;
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeInt32SizeNoTag(dataSize);
+ }
+ repeatedInt32MemoizedSerializedSize = dataSize;
+ }
+ for (int i = 0; i < repeatedMessage_.size(); i++) {
+ size += com.geedgenetworks.shaded.com.google.protobuf.CodedOutputStream
+ .computeMessageSize(15, repeatedMessage_.get(i));
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types)) {
+ return super.equals(obj);
+ }
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types other = (com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types) obj;
+
+ if (getInt64()
+ != other.getInt64()) return false;
+ if (getInt32()
+ != other.getInt32()) return false;
+ if (!getText()
+ .equals(other.getText())) return false;
+ if (!getBytes()
+ .equals(other.getBytes())) return false;
+ if (enumVal_ != other.enumVal_) return false;
+ if (hasMessage() != other.hasMessage()) return false;
+ if (hasMessage()) {
+ if (!getMessage()
+ .equals(other.getMessage())) return false;
+ }
+ if (hasOptionalInt64() != other.hasOptionalInt64()) return false;
+ if (hasOptionalInt64()) {
+ if (getOptionalInt64()
+ != other.getOptionalInt64()) return false;
+ }
+ if (hasOptionalInt32() != other.hasOptionalInt32()) return false;
+ if (hasOptionalInt32()) {
+ if (getOptionalInt32()
+ != other.getOptionalInt32()) return false;
+ }
+ if (hasOptionalText() != other.hasOptionalText()) return false;
+ if (hasOptionalText()) {
+ if (!getOptionalText()
+ .equals(other.getOptionalText())) return false;
+ }
+ if (hasOptionalBytes() != other.hasOptionalBytes()) return false;
+ if (hasOptionalBytes()) {
+ if (!getOptionalBytes()
+ .equals(other.getOptionalBytes())) return false;
+ }
+ if (hasOptionalEnumVal() != other.hasOptionalEnumVal()) return false;
+ if (hasOptionalEnumVal()) {
+ if (optionalEnumVal_ != other.optionalEnumVal_) return false;
+ }
+ if (hasOptionalMessage() != other.hasOptionalMessage()) return false;
+ if (hasOptionalMessage()) {
+ if (!getOptionalMessage()
+ .equals(other.getOptionalMessage())) return false;
+ }
+ if (!getRepeatedInt64List()
+ .equals(other.getRepeatedInt64List())) return false;
+ if (!getRepeatedInt32List()
+ .equals(other.getRepeatedInt32List())) return false;
+ if (!getRepeatedMessageList()
+ .equals(other.getRepeatedMessageList())) return false;
+ if (!getUnknownFields().equals(other.getUnknownFields())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + INT64_FIELD_NUMBER;
+ hash = (53 * hash) + com.geedgenetworks.shaded.com.google.protobuf.Internal.hashLong(
+ getInt64());
+ hash = (37 * hash) + INT32_FIELD_NUMBER;
+ hash = (53 * hash) + getInt32();
+ hash = (37 * hash) + TEXT_FIELD_NUMBER;
+ hash = (53 * hash) + getText().hashCode();
+ hash = (37 * hash) + BYTES_FIELD_NUMBER;
+ hash = (53 * hash) + getBytes().hashCode();
+ hash = (37 * hash) + ENUM_VAL_FIELD_NUMBER;
+ hash = (53 * hash) + enumVal_;
+ if (hasMessage()) {
+ hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
+ hash = (53 * hash) + getMessage().hashCode();
+ }
+ if (hasOptionalInt64()) {
+ hash = (37 * hash) + OPTIONAL_INT64_FIELD_NUMBER;
+ hash = (53 * hash) + com.geedgenetworks.shaded.com.google.protobuf.Internal.hashLong(
+ getOptionalInt64());
+ }
+ if (hasOptionalInt32()) {
+ hash = (37 * hash) + OPTIONAL_INT32_FIELD_NUMBER;
+ hash = (53 * hash) + getOptionalInt32();
+ }
+ if (hasOptionalText()) {
+ hash = (37 * hash) + OPTIONAL_TEXT_FIELD_NUMBER;
+ hash = (53 * hash) + getOptionalText().hashCode();
+ }
+ if (hasOptionalBytes()) {
+ hash = (37 * hash) + OPTIONAL_BYTES_FIELD_NUMBER;
+ hash = (53 * hash) + getOptionalBytes().hashCode();
+ }
+ if (hasOptionalEnumVal()) {
+ hash = (37 * hash) + OPTIONAL_ENUM_VAL_FIELD_NUMBER;
+ hash = (53 * hash) + optionalEnumVal_;
+ }
+ if (hasOptionalMessage()) {
+ hash = (37 * hash) + OPTIONAL_MESSAGE_FIELD_NUMBER;
+ hash = (53 * hash) + getOptionalMessage().hashCode();
+ }
+ if (getRepeatedInt64Count() > 0) {
+ hash = (37 * hash) + REPEATED_INT64_FIELD_NUMBER;
+ hash = (53 * hash) + getRepeatedInt64List().hashCode();
+ }
+ if (getRepeatedInt32Count() > 0) {
+ hash = (37 * hash) + REPEATED_INT32_FIELD_NUMBER;
+ hash = (53 * hash) + getRepeatedInt32List().hashCode();
+ }
+ if (getRepeatedMessageCount() > 0) {
+ hash = (37 * hash) + REPEATED_MESSAGE_FIELD_NUMBER;
+ hash = (53 * hash) + getRepeatedMessageList().hashCode();
+ }
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ java.nio.ByteBuffer data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(byte[] data)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ byte[] data,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ java.io.InputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseDelimitedFrom(
+ java.io.InputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types parseFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code Proto3Types}
+ */
+ public static final class Builder extends
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
+ // @@protoc_insertion_point(builder_implements:Proto3Types)
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3TypesOrBuilder {
+ public static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.class, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.Builder.class);
+ }
+
+ // Construct using com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3
+ .alwaysUseFieldBuilders) {
+ getMessageFieldBuilder();
+ getOptionalMessageFieldBuilder();
+ getRepeatedMessageFieldBuilder();
+ }
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ bitField0_ = 0;
+ int64_ = 0L;
+ int32_ = 0;
+ text_ = "";
+ bytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ enumVal_ = 0;
+ message_ = null;
+ if (messageBuilder_ != null) {
+ messageBuilder_.dispose();
+ messageBuilder_ = null;
+ }
+ optionalInt64_ = 0L;
+ optionalInt32_ = 0;
+ optionalText_ = "";
+ optionalBytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ optionalEnumVal_ = 0;
+ optionalMessage_ = null;
+ if (optionalMessageBuilder_ != null) {
+ optionalMessageBuilder_.dispose();
+ optionalMessageBuilder_ = null;
+ }
+ repeatedInt64_ = emptyLongList();
+ repeatedInt32_ = emptyIntList();
+ if (repeatedMessageBuilder_ == null) {
+ repeatedMessage_ = java.util.Collections.emptyList();
+ } else {
+ repeatedMessage_ = null;
+ repeatedMessageBuilder_.clear();
+ }
+ bitField0_ = (bitField0_ & ~0x00004000);
+ return this;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.internal_static_Proto3Types_descriptor;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstanceForType() {
+ return com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types build() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types buildPartial() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types(this);
+ buildPartialRepeatedFields(result);
+ if (bitField0_ != 0) { buildPartial0(result); }
+ onBuilt();
+ return result;
+ }
+
+ private void buildPartialRepeatedFields(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result) {
+ if (((bitField0_ & 0x00001000) != 0)) {
+ repeatedInt64_.makeImmutable();
+ bitField0_ = (bitField0_ & ~0x00001000);
+ }
+ result.repeatedInt64_ = repeatedInt64_;
+ if (((bitField0_ & 0x00002000) != 0)) {
+ repeatedInt32_.makeImmutable();
+ bitField0_ = (bitField0_ & ~0x00002000);
+ }
+ result.repeatedInt32_ = repeatedInt32_;
+ if (repeatedMessageBuilder_ == null) {
+ if (((bitField0_ & 0x00004000) != 0)) {
+ repeatedMessage_ = java.util.Collections.unmodifiableList(repeatedMessage_);
+ bitField0_ = (bitField0_ & ~0x00004000);
+ }
+ result.repeatedMessage_ = repeatedMessage_;
+ } else {
+ result.repeatedMessage_ = repeatedMessageBuilder_.build();
+ }
+ }
+
+ private void buildPartial0(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types result) {
+ int from_bitField0_ = bitField0_;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.int64_ = int64_;
+ }
+ if (((from_bitField0_ & 0x00000002) != 0)) {
+ result.int32_ = int32_;
+ }
+ if (((from_bitField0_ & 0x00000004) != 0)) {
+ result.text_ = text_;
+ }
+ if (((from_bitField0_ & 0x00000008) != 0)) {
+ result.bytes_ = bytes_;
+ }
+ if (((from_bitField0_ & 0x00000010) != 0)) {
+ result.enumVal_ = enumVal_;
+ }
+ if (((from_bitField0_ & 0x00000020) != 0)) {
+ result.message_ = messageBuilder_ == null
+ ? message_
+ : messageBuilder_.build();
+ }
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000040) != 0)) {
+ result.optionalInt64_ = optionalInt64_;
+ to_bitField0_ |= 0x00000001;
+ }
+ if (((from_bitField0_ & 0x00000080) != 0)) {
+ result.optionalInt32_ = optionalInt32_;
+ to_bitField0_ |= 0x00000002;
+ }
+ if (((from_bitField0_ & 0x00000100) != 0)) {
+ result.optionalText_ = optionalText_;
+ to_bitField0_ |= 0x00000004;
+ }
+ if (((from_bitField0_ & 0x00000200) != 0)) {
+ result.optionalBytes_ = optionalBytes_;
+ to_bitField0_ |= 0x00000008;
+ }
+ if (((from_bitField0_ & 0x00000400) != 0)) {
+ result.optionalEnumVal_ = optionalEnumVal_;
+ to_bitField0_ |= 0x00000010;
+ }
+ if (((from_bitField0_ & 0x00000800) != 0)) {
+ result.optionalMessage_ = optionalMessageBuilder_ == null
+ ? optionalMessage_
+ : optionalMessageBuilder_.build();
+ to_bitField0_ |= 0x00000020;
+ }
+ result.bitField0_ |= to_bitField0_;
+ }
+
+ @java.lang.Override
+ public Builder clone() {
+ return super.clone();
+ }
+ @java.lang.Override
+ public Builder setField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.setField(field, value);
+ }
+ @java.lang.Override
+ public Builder clearField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field) {
+ return super.clearField(field);
+ }
+ @java.lang.Override
+ public Builder clearOneof(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.OneofDescriptor oneof) {
+ return super.clearOneof(oneof);
+ }
+ @java.lang.Override
+ public Builder setRepeatedField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ int index, java.lang.Object value) {
+ return super.setRepeatedField(field, index, value);
+ }
+ @java.lang.Override
+ public Builder addRepeatedField(
+ com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FieldDescriptor field,
+ java.lang.Object value) {
+ return super.addRepeatedField(field, value);
+ }
+ @java.lang.Override
+ public Builder mergeFrom(com.geedgenetworks.shaded.com.google.protobuf.Message other) {
+ if (other instanceof com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types) {
+ return mergeFrom((com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types other) {
+ if (other == com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.getDefaultInstance()) return this;
+ if (other.getInt64() != 0L) {
+ setInt64(other.getInt64());
+ }
+ if (other.getInt32() != 0) {
+ setInt32(other.getInt32());
+ }
+ if (!other.getText().isEmpty()) {
+ text_ = other.text_;
+ bitField0_ |= 0x00000004;
+ onChanged();
+ }
+ if (other.getBytes() != com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY) {
+ setBytes(other.getBytes());
+ }
+ if (other.enumVal_ != 0) {
+ setEnumValValue(other.getEnumValValue());
+ }
+ if (other.hasMessage()) {
+ mergeMessage(other.getMessage());
+ }
+ if (other.hasOptionalInt64()) {
+ setOptionalInt64(other.getOptionalInt64());
+ }
+ if (other.hasOptionalInt32()) {
+ setOptionalInt32(other.getOptionalInt32());
+ }
+ if (other.hasOptionalText()) {
+ optionalText_ = other.optionalText_;
+ bitField0_ |= 0x00000100;
+ onChanged();
+ }
+ if (other.hasOptionalBytes()) {
+ setOptionalBytes(other.getOptionalBytes());
+ }
+ if (other.hasOptionalEnumVal()) {
+ setOptionalEnumVal(other.getOptionalEnumVal());
+ }
+ if (other.hasOptionalMessage()) {
+ mergeOptionalMessage(other.getOptionalMessage());
+ }
+ if (!other.repeatedInt64_.isEmpty()) {
+ if (repeatedInt64_.isEmpty()) {
+ repeatedInt64_ = other.repeatedInt64_;
+ bitField0_ = (bitField0_ & ~0x00001000);
+ } else {
+ ensureRepeatedInt64IsMutable();
+ repeatedInt64_.addAll(other.repeatedInt64_);
+ }
+ onChanged();
+ }
+ if (!other.repeatedInt32_.isEmpty()) {
+ if (repeatedInt32_.isEmpty()) {
+ repeatedInt32_ = other.repeatedInt32_;
+ bitField0_ = (bitField0_ & ~0x00002000);
+ } else {
+ ensureRepeatedInt32IsMutable();
+ repeatedInt32_.addAll(other.repeatedInt32_);
+ }
+ onChanged();
+ }
+ if (repeatedMessageBuilder_ == null) {
+ if (!other.repeatedMessage_.isEmpty()) {
+ if (repeatedMessage_.isEmpty()) {
+ repeatedMessage_ = other.repeatedMessage_;
+ bitField0_ = (bitField0_ & ~0x00004000);
+ } else {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.addAll(other.repeatedMessage_);
+ }
+ onChanged();
+ }
+ } else {
+ if (!other.repeatedMessage_.isEmpty()) {
+ if (repeatedMessageBuilder_.isEmpty()) {
+ repeatedMessageBuilder_.dispose();
+ repeatedMessageBuilder_ = null;
+ repeatedMessage_ = other.repeatedMessage_;
+ bitField0_ = (bitField0_ & ~0x00004000);
+ repeatedMessageBuilder_ =
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+ getRepeatedMessageFieldBuilder() : null;
+ } else {
+ repeatedMessageBuilder_.addAllMessages(other.repeatedMessage_);
+ }
+ }
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 8: {
+ int64_ = input.readInt64();
+ bitField0_ |= 0x00000001;
+ break;
+ } // case 8
+ case 16: {
+ int32_ = input.readInt32();
+ bitField0_ |= 0x00000002;
+ break;
+ } // case 16
+ case 26: {
+ text_ = input.readStringRequireUtf8();
+ bitField0_ |= 0x00000004;
+ break;
+ } // case 26
+ case 34: {
+ bytes_ = input.readBytes();
+ bitField0_ |= 0x00000008;
+ break;
+ } // case 34
+ case 40: {
+ enumVal_ = input.readEnum();
+ bitField0_ |= 0x00000010;
+ break;
+ } // case 40
+ case 50: {
+ input.readMessage(
+ getMessageFieldBuilder().getBuilder(),
+ extensionRegistry);
+ bitField0_ |= 0x00000020;
+ break;
+ } // case 50
+ case 56: {
+ optionalInt64_ = input.readInt64();
+ bitField0_ |= 0x00000040;
+ break;
+ } // case 56
+ case 64: {
+ optionalInt32_ = input.readInt32();
+ bitField0_ |= 0x00000080;
+ break;
+ } // case 64
+ case 74: {
+ optionalText_ = input.readStringRequireUtf8();
+ bitField0_ |= 0x00000100;
+ break;
+ } // case 74
+ case 82: {
+ optionalBytes_ = input.readBytes();
+ bitField0_ |= 0x00000200;
+ break;
+ } // case 82
+ case 88: {
+ optionalEnumVal_ = input.readEnum();
+ bitField0_ |= 0x00000400;
+ break;
+ } // case 88
+ case 98: {
+ input.readMessage(
+ getOptionalMessageFieldBuilder().getBuilder(),
+ extensionRegistry);
+ bitField0_ |= 0x00000800;
+ break;
+ } // case 98
+ case 104: {
+ long v = input.readInt64();
+ ensureRepeatedInt64IsMutable();
+ repeatedInt64_.addLong(v);
+ break;
+ } // case 104
+ case 106: {
+ int length = input.readRawVarint32();
+ int limit = input.pushLimit(length);
+ ensureRepeatedInt64IsMutable();
+ while (input.getBytesUntilLimit() > 0) {
+ repeatedInt64_.addLong(input.readInt64());
+ }
+ input.popLimit(limit);
+ break;
+ } // case 106
+ case 112: {
+ int v = input.readInt32();
+ ensureRepeatedInt32IsMutable();
+ repeatedInt32_.addInt(v);
+ break;
+ } // case 112
+ case 114: {
+ int length = input.readRawVarint32();
+ int limit = input.pushLimit(length);
+ ensureRepeatedInt32IsMutable();
+ while (input.getBytesUntilLimit() > 0) {
+ repeatedInt32_.addInt(input.readInt32());
+ }
+ input.popLimit(limit);
+ break;
+ } // case 114
+ case 122: {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage m =
+ input.readMessage(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.parser(),
+ extensionRegistry);
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.add(m);
+ } else {
+ repeatedMessageBuilder_.addMessage(m);
+ }
+ break;
+ } // case 122
+ default: {
+ if (!super.parseUnknownField(input, extensionRegistry, tag)) {
+ done = true; // was an endgroup tag
+ }
+ break;
+ } // default:
+ } // switch (tag)
+ } // while (!done)
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ } finally {
+ onChanged();
+ } // finally
+ return this;
+ }
+ private int bitField0_;
+
+ private long int64_ ;
+ /**
+ * <code>int64 int64 = 1;</code>
+ * @return The int64.
+ */
+ @java.lang.Override
+ public long getInt64() {
+ return int64_;
+ }
+ /**
+ * <code>int64 int64 = 1;</code>
+ * @param value The int64 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setInt64(long value) {
+
+ int64_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>int64 int64 = 1;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearInt64() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ int64_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private int int32_ ;
+ /**
+ * <code>int32 int32 = 2;</code>
+ * @return The int32.
+ */
+ @java.lang.Override
+ public int getInt32() {
+ return int32_;
+ }
+ /**
+ * <code>int32 int32 = 2;</code>
+ * @param value The int32 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setInt32(int value) {
+
+ int32_ = value;
+ bitField0_ |= 0x00000002;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>int32 int32 = 2;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearInt32() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ int32_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object text_ = "";
+ /**
+ * <code>string text = 3;</code>
+ * @return The text.
+ */
+ public java.lang.String getText() {
+ java.lang.Object ref = text_;
+ if (!(ref instanceof java.lang.String)) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ text_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>string text = 3;</code>
+ * @return The bytes for text.
+ */
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getTextBytes() {
+ java.lang.Object ref = text_;
+ if (ref instanceof String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ text_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>string text = 3;</code>
+ * @param value The text to set.
+ * @return This builder for chaining.
+ */
+ public Builder setText(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ text_ = value;
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string text = 3;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearText() {
+ text_ = getDefaultInstance().getText();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>string text = 3;</code>
+ * @param value The bytes for text to set.
+ * @return This builder for chaining.
+ */
+ public Builder setTextBytes(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ text_ = value;
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return this;
+ }
+
+ private com.geedgenetworks.shaded.com.google.protobuf.ByteString bytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>bytes bytes = 4;</code>
+ * @return The bytes.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString getBytes() {
+ return bytes_;
+ }
+ /**
+ * <code>bytes bytes = 4;</code>
+ * @param value The bytes to set.
+ * @return This builder for chaining.
+ */
+ public Builder setBytes(com.geedgenetworks.shaded.com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ bytes_ = value;
+ bitField0_ |= 0x00000008;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>bytes bytes = 4;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearBytes() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ bytes_ = getDefaultInstance().getBytes();
+ onChanged();
+ return this;
+ }
+
+ private int enumVal_ = 0;
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enum numeric value on the wire for enumVal.
+ */
+ @java.lang.Override public int getEnumValValue() {
+ return enumVal_;
+ }
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @param value The enum numeric value on the wire for enumVal to set.
+ * @return This builder for chaining.
+ */
+ public Builder setEnumValValue(int value) {
+ enumVal_ = value;
+ bitField0_ |= 0x00000010;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return The enumVal.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getEnumVal() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(enumVal_);
+ return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
+ }
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @param value The enumVal to set.
+ * @return This builder for chaining.
+ */
+ public Builder setEnumVal(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000010;
+ enumVal_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.Proto3Types.NestedEnum enum_val = 5;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearEnumVal() {
+ bitField0_ = (bitField0_ & ~0x00000010);
+ enumVal_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage message_;
+ private com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> messageBuilder_;
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return Whether the message field is set.
+ */
+ public boolean hasMessage() {
+ return ((bitField0_ & 0x00000020) != 0);
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ * @return The message.
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getMessage() {
+ if (messageBuilder_ == null) {
+ return message_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
+ } else {
+ return messageBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public Builder setMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (messageBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ message_ = value;
+ } else {
+ messageBuilder_.setMessage(value);
+ }
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public Builder setMessage(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
+ if (messageBuilder_ == null) {
+ message_ = builderForValue.build();
+ } else {
+ messageBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public Builder mergeMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (messageBuilder_ == null) {
+ if (((bitField0_ & 0x00000020) != 0) &&
+ message_ != null &&
+ message_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) {
+ getMessageBuilder().mergeFrom(value);
+ } else {
+ message_ = value;
+ }
+ } else {
+ messageBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public Builder clearMessage() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ message_ = null;
+ if (messageBuilder_ != null) {
+ messageBuilder_.dispose();
+ messageBuilder_ = null;
+ }
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getMessageBuilder() {
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return getMessageFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getMessageOrBuilder() {
+ if (messageBuilder_ != null) {
+ return messageBuilder_.getMessageOrBuilder();
+ } else {
+ return message_ == null ?
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : message_;
+ }
+ }
+ /**
+ * <code>.StructMessage message = 6;</code>
+ */
+ private com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getMessageFieldBuilder() {
+ if (messageBuilder_ == null) {
+ messageBuilder_ = new com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
+ getMessage(),
+ getParentForChildren(),
+ isClean());
+ message_ = null;
+ }
+ return messageBuilder_;
+ }
+
+ private long optionalInt64_ ;
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return Whether the optionalInt64 field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalInt64() {
+ return ((bitField0_ & 0x00000040) != 0);
+ }
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return The optionalInt64.
+ */
+ @java.lang.Override
+ public long getOptionalInt64() {
+ return optionalInt64_;
+ }
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @param value The optionalInt64 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalInt64(long value) {
+
+ optionalInt64_ = value;
+ bitField0_ |= 0x00000040;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int64 optional_int64 = 7;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalInt64() {
+ bitField0_ = (bitField0_ & ~0x00000040);
+ optionalInt64_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private int optionalInt32_ ;
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return Whether the optionalInt32 field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalInt32() {
+ return ((bitField0_ & 0x00000080) != 0);
+ }
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return The optionalInt32.
+ */
+ @java.lang.Override
+ public int getOptionalInt32() {
+ return optionalInt32_;
+ }
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @param value The optionalInt32 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalInt32(int value) {
+
+ optionalInt32_ = value;
+ bitField0_ |= 0x00000080;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional int32 optional_int32 = 8;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalInt32() {
+ bitField0_ = (bitField0_ & ~0x00000080);
+ optionalInt32_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private java.lang.Object optionalText_ = "";
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return Whether the optionalText field is set.
+ */
+ public boolean hasOptionalText() {
+ return ((bitField0_ & 0x00000100) != 0);
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The optionalText.
+ */
+ public java.lang.String getOptionalText() {
+ java.lang.Object ref = optionalText_;
+ if (!(ref instanceof java.lang.String)) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString bs =
+ (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ java.lang.String s = bs.toStringUtf8();
+ optionalText_ = s;
+ return s;
+ } else {
+ return (java.lang.String) ref;
+ }
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return The bytes for optionalText.
+ */
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString
+ getOptionalTextBytes() {
+ java.lang.Object ref = optionalText_;
+ if (ref instanceof String) {
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString b =
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString.copyFromUtf8(
+ (java.lang.String) ref);
+ optionalText_ = b;
+ return b;
+ } else {
+ return (com.geedgenetworks.shaded.com.google.protobuf.ByteString) ref;
+ }
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @param value The optionalText to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalText(
+ java.lang.String value) {
+ if (value == null) { throw new NullPointerException(); }
+ optionalText_ = value;
+ bitField0_ |= 0x00000100;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalText() {
+ optionalText_ = getDefaultInstance().getOptionalText();
+ bitField0_ = (bitField0_ & ~0x00000100);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional string optional_text = 9;</code>
+ * @param value The bytes for optionalText to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalTextBytes(
+ com.geedgenetworks.shaded.com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ checkByteStringIsUtf8(value);
+ optionalText_ = value;
+ bitField0_ |= 0x00000100;
+ onChanged();
+ return this;
+ }
+
+ private com.geedgenetworks.shaded.com.google.protobuf.ByteString optionalBytes_ = com.geedgenetworks.shaded.com.google.protobuf.ByteString.EMPTY;
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return Whether the optionalBytes field is set.
+ */
+ @java.lang.Override
+ public boolean hasOptionalBytes() {
+ return ((bitField0_ & 0x00000200) != 0);
+ }
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return The optionalBytes.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.ByteString getOptionalBytes() {
+ return optionalBytes_;
+ }
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @param value The optionalBytes to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalBytes(com.geedgenetworks.shaded.com.google.protobuf.ByteString value) {
+ if (value == null) { throw new NullPointerException(); }
+ optionalBytes_ = value;
+ bitField0_ |= 0x00000200;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bytes optional_bytes = 10;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalBytes() {
+ bitField0_ = (bitField0_ & ~0x00000200);
+ optionalBytes_ = getDefaultInstance().getOptionalBytes();
+ onChanged();
+ return this;
+ }
+
+ private int optionalEnumVal_ = 0;
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return Whether the optionalEnumVal field is set.
+ */
+ @java.lang.Override public boolean hasOptionalEnumVal() {
+ return ((bitField0_ & 0x00000400) != 0);
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The enum numeric value on the wire for optionalEnumVal.
+ */
+ @java.lang.Override public int getOptionalEnumValValue() {
+ return optionalEnumVal_;
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @param value The enum numeric value on the wire for optionalEnumVal to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalEnumValValue(int value) {
+ optionalEnumVal_ = value;
+ bitField0_ |= 0x00000400;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return The optionalEnumVal.
+ */
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum getOptionalEnumVal() {
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum result = com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.forNumber(optionalEnumVal_);
+ return result == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum.UNRECOGNIZED : result;
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @param value The optionalEnumVal to set.
+ * @return This builder for chaining.
+ */
+ public Builder setOptionalEnumVal(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types.NestedEnum value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000400;
+ optionalEnumVal_ = value.getNumber();
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .Proto3Types.NestedEnum optional_enum_val = 11;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearOptionalEnumVal() {
+ bitField0_ = (bitField0_ & ~0x00000400);
+ optionalEnumVal_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage optionalMessage_;
+ private com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> optionalMessageBuilder_;
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return Whether the optionalMessage field is set.
+ */
+ public boolean hasOptionalMessage() {
+ return ((bitField0_ & 0x00000800) != 0);
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ * @return The optionalMessage.
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getOptionalMessage() {
+ if (optionalMessageBuilder_ == null) {
+ return optionalMessage_ == null ? com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
+ } else {
+ return optionalMessageBuilder_.getMessage();
+ }
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public Builder setOptionalMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (optionalMessageBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ optionalMessage_ = value;
+ } else {
+ optionalMessageBuilder_.setMessage(value);
+ }
+ bitField0_ |= 0x00000800;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public Builder setOptionalMessage(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
+ if (optionalMessageBuilder_ == null) {
+ optionalMessage_ = builderForValue.build();
+ } else {
+ optionalMessageBuilder_.setMessage(builderForValue.build());
+ }
+ bitField0_ |= 0x00000800;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public Builder mergeOptionalMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (optionalMessageBuilder_ == null) {
+ if (((bitField0_ & 0x00000800) != 0) &&
+ optionalMessage_ != null &&
+ optionalMessage_ != com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance()) {
+ getOptionalMessageBuilder().mergeFrom(value);
+ } else {
+ optionalMessage_ = value;
+ }
+ } else {
+ optionalMessageBuilder_.mergeFrom(value);
+ }
+ bitField0_ |= 0x00000800;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public Builder clearOptionalMessage() {
+ bitField0_ = (bitField0_ & ~0x00000800);
+ optionalMessage_ = null;
+ if (optionalMessageBuilder_ != null) {
+ optionalMessageBuilder_.dispose();
+ optionalMessageBuilder_ = null;
+ }
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getOptionalMessageBuilder() {
+ bitField0_ |= 0x00000800;
+ onChanged();
+ return getOptionalMessageFieldBuilder().getBuilder();
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getOptionalMessageOrBuilder() {
+ if (optionalMessageBuilder_ != null) {
+ return optionalMessageBuilder_.getMessageOrBuilder();
+ } else {
+ return optionalMessage_ == null ?
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance() : optionalMessage_;
+ }
+ }
+ /**
+ * <code>optional .StructMessage optional_message = 12;</code>
+ */
+ private com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getOptionalMessageFieldBuilder() {
+ if (optionalMessageBuilder_ == null) {
+ optionalMessageBuilder_ = new com.geedgenetworks.shaded.com.google.protobuf.SingleFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
+ getOptionalMessage(),
+ getParentForChildren(),
+ isClean());
+ optionalMessage_ = null;
+ }
+ return optionalMessageBuilder_;
+ }
+
+ private com.geedgenetworks.shaded.com.google.protobuf.Internal.LongList repeatedInt64_ = emptyLongList();
+ private void ensureRepeatedInt64IsMutable() {
+ if (!((bitField0_ & 0x00001000) != 0)) {
+ repeatedInt64_ = mutableCopy(repeatedInt64_);
+ bitField0_ |= 0x00001000;
+ }
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return A list containing the repeatedInt64.
+ */
+ public java.util.List<java.lang.Long>
+ getRepeatedInt64List() {
+ return ((bitField0_ & 0x00001000) != 0) ?
+ java.util.Collections.unmodifiableList(repeatedInt64_) : repeatedInt64_;
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return The count of repeatedInt64.
+ */
+ public int getRepeatedInt64Count() {
+ return repeatedInt64_.size();
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt64 at the given index.
+ */
+ public long getRepeatedInt64(int index) {
+ return repeatedInt64_.getLong(index);
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param index The index to set the value at.
+ * @param value The repeatedInt64 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRepeatedInt64(
+ int index, long value) {
+
+ ensureRepeatedInt64IsMutable();
+ repeatedInt64_.setLong(index, value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param value The repeatedInt64 to add.
+ * @return This builder for chaining.
+ */
+ public Builder addRepeatedInt64(long value) {
+
+ ensureRepeatedInt64IsMutable();
+ repeatedInt64_.addLong(value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @param values The repeatedInt64 to add.
+ * @return This builder for chaining.
+ */
+ public Builder addAllRepeatedInt64(
+ java.lang.Iterable<? extends java.lang.Long> values) {
+ ensureRepeatedInt64IsMutable();
+ com.geedgenetworks.shaded.com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, repeatedInt64_);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int64 repeated_int64 = 13;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearRepeatedInt64() {
+ repeatedInt64_ = emptyLongList();
+ bitField0_ = (bitField0_ & ~0x00001000);
+ onChanged();
+ return this;
+ }
+
+ private com.geedgenetworks.shaded.com.google.protobuf.Internal.IntList repeatedInt32_ = emptyIntList();
+ private void ensureRepeatedInt32IsMutable() {
+ if (!((bitField0_ & 0x00002000) != 0)) {
+ repeatedInt32_ = mutableCopy(repeatedInt32_);
+ bitField0_ |= 0x00002000;
+ }
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return A list containing the repeatedInt32.
+ */
+ public java.util.List<java.lang.Integer>
+ getRepeatedInt32List() {
+ return ((bitField0_ & 0x00002000) != 0) ?
+ java.util.Collections.unmodifiableList(repeatedInt32_) : repeatedInt32_;
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return The count of repeatedInt32.
+ */
+ public int getRepeatedInt32Count() {
+ return repeatedInt32_.size();
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param index The index of the element to return.
+ * @return The repeatedInt32 at the given index.
+ */
+ public int getRepeatedInt32(int index) {
+ return repeatedInt32_.getInt(index);
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param index The index to set the value at.
+ * @param value The repeatedInt32 to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRepeatedInt32(
+ int index, int value) {
+
+ ensureRepeatedInt32IsMutable();
+ repeatedInt32_.setInt(index, value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param value The repeatedInt32 to add.
+ * @return This builder for chaining.
+ */
+ public Builder addRepeatedInt32(int value) {
+
+ ensureRepeatedInt32IsMutable();
+ repeatedInt32_.addInt(value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @param values The repeatedInt32 to add.
+ * @return This builder for chaining.
+ */
+ public Builder addAllRepeatedInt32(
+ java.lang.Iterable<? extends java.lang.Integer> values) {
+ ensureRepeatedInt32IsMutable();
+ com.geedgenetworks.shaded.com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, repeatedInt32_);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated int32 repeated_int32 = 14;</code>
+ * @return This builder for chaining.
+ */
+ public Builder clearRepeatedInt32() {
+ repeatedInt32_ = emptyIntList();
+ bitField0_ = (bitField0_ & ~0x00002000);
+ onChanged();
+ return this;
+ }
+
+ private java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> repeatedMessage_ =
+ java.util.Collections.emptyList();
+ private void ensureRepeatedMessageIsMutable() {
+ if (!((bitField0_ & 0x00004000) != 0)) {
+ repeatedMessage_ = new java.util.ArrayList<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage>(repeatedMessage_);
+ bitField0_ |= 0x00004000;
+ }
+ }
+
+ private com.geedgenetworks.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder> repeatedMessageBuilder_;
+
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> getRepeatedMessageList() {
+ if (repeatedMessageBuilder_ == null) {
+ return java.util.Collections.unmodifiableList(repeatedMessage_);
+ } else {
+ return repeatedMessageBuilder_.getMessageList();
+ }
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public int getRepeatedMessageCount() {
+ if (repeatedMessageBuilder_ == null) {
+ return repeatedMessage_.size();
+ } else {
+ return repeatedMessageBuilder_.getCount();
+ }
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage getRepeatedMessage(int index) {
+ if (repeatedMessageBuilder_ == null) {
+ return repeatedMessage_.get(index);
+ } else {
+ return repeatedMessageBuilder_.getMessage(index);
+ }
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder setRepeatedMessage(
+ int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (repeatedMessageBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.set(index, value);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.setMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder setRepeatedMessage(
+ int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.set(index, builderForValue.build());
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.setMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder addRepeatedMessage(com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (repeatedMessageBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.add(value);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.addMessage(value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder addRepeatedMessage(
+ int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage value) {
+ if (repeatedMessageBuilder_ == null) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.add(index, value);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.addMessage(index, value);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder addRepeatedMessage(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.add(builderForValue.build());
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.addMessage(builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder addRepeatedMessage(
+ int index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder builderForValue) {
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.add(index, builderForValue.build());
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.addMessage(index, builderForValue.build());
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder addAllRepeatedMessage(
+ java.lang.Iterable<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage> values) {
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ com.geedgenetworks.shaded.com.google.protobuf.AbstractMessageLite.Builder.addAll(
+ values, repeatedMessage_);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.addAllMessages(values);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder clearRepeatedMessage() {
+ if (repeatedMessageBuilder_ == null) {
+ repeatedMessage_ = java.util.Collections.emptyList();
+ bitField0_ = (bitField0_ & ~0x00004000);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.clear();
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public Builder removeRepeatedMessage(int index) {
+ if (repeatedMessageBuilder_ == null) {
+ ensureRepeatedMessageIsMutable();
+ repeatedMessage_.remove(index);
+ onChanged();
+ } else {
+ repeatedMessageBuilder_.remove(index);
+ }
+ return this;
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder getRepeatedMessageBuilder(
+ int index) {
+ return getRepeatedMessageFieldBuilder().getBuilder(index);
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder getRepeatedMessageOrBuilder(
+ int index) {
+ if (repeatedMessageBuilder_ == null) {
+ return repeatedMessage_.get(index); } else {
+ return repeatedMessageBuilder_.getMessageOrBuilder(index);
+ }
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public java.util.List<? extends com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getRepeatedMessageOrBuilderList() {
+ if (repeatedMessageBuilder_ != null) {
+ return repeatedMessageBuilder_.getMessageOrBuilderList();
+ } else {
+ return java.util.Collections.unmodifiableList(repeatedMessage_);
+ }
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder addRepeatedMessageBuilder() {
+ return getRepeatedMessageFieldBuilder().addBuilder(
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder addRepeatedMessageBuilder(
+ int index) {
+ return getRepeatedMessageFieldBuilder().addBuilder(
+ index, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.getDefaultInstance());
+ }
+ /**
+ * <code>repeated .StructMessage repeated_message = 15;</code>
+ */
+ public java.util.List<com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder>
+ getRepeatedMessageBuilderList() {
+ return getRepeatedMessageFieldBuilder().getBuilderList();
+ }
+ private com.geedgenetworks.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>
+ getRepeatedMessageFieldBuilder() {
+ if (repeatedMessageBuilder_ == null) {
+ repeatedMessageBuilder_ = new com.geedgenetworks.shaded.com.google.protobuf.RepeatedFieldBuilderV3<
+ com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessage.Builder, com.geedgenetworks.formats.protobuf.Proto3TypesProtos.StructMessageOrBuilder>(
+ repeatedMessage_,
+ ((bitField0_ & 0x00004000) != 0),
+ getParentForChildren(),
+ isClean());
+ repeatedMessage_ = null;
+ }
+ return repeatedMessageBuilder_;
+ }
+ @java.lang.Override
+ public final Builder setUnknownFields(
+ final com.geedgenetworks.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.setUnknownFields(unknownFields);
+ }
+
+ @java.lang.Override
+ public final Builder mergeUnknownFields(
+ final com.geedgenetworks.shaded.com.google.protobuf.UnknownFieldSet unknownFields) {
+ return super.mergeUnknownFields(unknownFields);
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:Proto3Types)
+ }
+
+ // @@protoc_insertion_point(class_scope:Proto3Types)
+ private static final com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types();
+ }
+
+ public static com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.geedgenetworks.shaded.com.google.protobuf.Parser<Proto3Types>
+ PARSER = new com.geedgenetworks.shaded.com.google.protobuf.AbstractParser<Proto3Types>() {
+ @java.lang.Override
+ public Proto3Types parsePartialFrom(
+ com.geedgenetworks.shaded.com.google.protobuf.CodedInputStream input,
+ com.geedgenetworks.shaded.com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException {
+ Builder builder = newBuilder();
+ try {
+ builder.mergeFrom(input, extensionRegistry);
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(builder.buildPartial());
+ } catch (com.geedgenetworks.shaded.com.google.protobuf.UninitializedMessageException e) {
+ throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
+ } catch (java.io.IOException e) {
+ throw new com.geedgenetworks.shaded.com.google.protobuf.InvalidProtocolBufferException(e)
+ .setUnfinishedMessage(builder.buildPartial());
+ }
+ return builder.buildPartial();
+ }
+ };
+
+ public static com.geedgenetworks.shaded.com.google.protobuf.Parser<Proto3Types> parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.shaded.com.google.protobuf.Parser<Proto3Types> getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.geedgenetworks.formats.protobuf.Proto3TypesProtos.Proto3Types getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ internal_static_StructMessage_descriptor;
+ private static final
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_StructMessage_fieldAccessorTable;
+ private static final com.geedgenetworks.shaded.com.google.protobuf.Descriptors.Descriptor
+ internal_static_Proto3Types_descriptor;
+ private static final
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+ internal_static_Proto3Types_fieldAccessorTable;
+
+ public static com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\022proto3_types.proto\"\233\001\n\rStructMessage\022\n" +
+ "\n\002id\030\001 \001(\003\022\014\n\004name\030\002 \001(\t\022\013\n\003age\030\003 \001(\005\022\r\n" +
+ "\005score\030\004 \001(\001\022\030\n\013optional_id\030\005 \001(\003H\000\210\001\001\022\031" +
+ "\n\014optional_age\030\006 \001(\005H\001\210\001\001B\016\n\014_optional_i" +
+ "dB\017\n\r_optional_age\"\361\004\n\013Proto3Types\022\r\n\005in" +
+ "t64\030\001 \001(\003\022\r\n\005int32\030\002 \001(\005\022\014\n\004text\030\003 \001(\t\022\r" +
+ "\n\005bytes\030\004 \001(\014\022)\n\010enum_val\030\005 \001(\0162\027.Proto3" +
+ "Types.NestedEnum\022\037\n\007message\030\006 \001(\0132\016.Stru" +
+ "ctMessage\022\033\n\016optional_int64\030\007 \001(\003H\000\210\001\001\022\033" +
+ "\n\016optional_int32\030\010 \001(\005H\001\210\001\001\022\032\n\roptional_" +
+ "text\030\t \001(\tH\002\210\001\001\022\033\n\016optional_bytes\030\n \001(\014H" +
+ "\003\210\001\001\0227\n\021optional_enum_val\030\013 \001(\0162\027.Proto3" +
+ "Types.NestedEnumH\004\210\001\001\022-\n\020optional_messag" +
+ "e\030\014 \001(\0132\016.StructMessageH\005\210\001\001\022\026\n\016repeated" +
+ "_int64\030\r \003(\003\022\026\n\016repeated_int32\030\016 \003(\005\022(\n\020" +
+ "repeated_message\030\017 \003(\0132\016.StructMessage\"0" +
+ "\n\nNestedEnum\022\013\n\007NOTHING\020\000\022\t\n\005FIRST\020\001\022\n\n\006" +
+ "SECOND\020\002B\021\n\017_optional_int64B\021\n\017_optional" +
+ "_int32B\020\n\016_optional_textB\021\n\017_optional_by" +
+ "tesB\024\n\022_optional_enum_valB\023\n\021_optional_m" +
+ "essageB8\n#com.geedgenetworks.formats.pro" +
+ "tobufB\021Proto3TypesProtosb\006proto3"
+ };
+ descriptor = com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.geedgenetworks.shaded.com.google.protobuf.Descriptors.FileDescriptor[] {
+ });
+ internal_static_StructMessage_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_StructMessage_fieldAccessorTable = new
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_StructMessage_descriptor,
+ new java.lang.String[] { "Id", "Name", "Age", "Score", "OptionalId", "OptionalAge", "OptionalId", "OptionalAge", });
+ internal_static_Proto3Types_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_Proto3Types_fieldAccessorTable = new
+ com.geedgenetworks.shaded.com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+ internal_static_Proto3Types_descriptor,
+ new java.lang.String[] { "Int64", "Int32", "Text", "Bytes", "EnumVal", "Message", "OptionalInt64", "OptionalInt32", "OptionalText", "OptionalBytes", "OptionalEnumVal", "OptionalMessage", "RepeatedInt64", "RepeatedInt32", "RepeatedMessage", "OptionalInt64", "OptionalInt32", "OptionalText", "OptionalBytes", "OptionalEnumVal", "OptionalMessage", });
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufEventSchemaTest.java b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufEventSchemaTest.java
index 707b0fe..1dcf928 100644
--- a/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufEventSchemaTest.java
+++ b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufEventSchemaTest.java
@@ -1,598 +1,692 @@
-package com.geedgenetworks.formats.protobuf;
-
-import com.alibaba.fastjson2.JSON;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.Descriptors;
-import org.junit.jupiter.api.Test;
-import com.geedgenetworks.formats.protobuf.SchemaConverters.MessageConverter;
-
-import java.util.*;
-import java.util.concurrent.ThreadLocalRandom;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * protoc --descriptor_set_out=proto3_types.desc --java_out=./ proto3_types.proto
- * protoc --descriptor_set_out=session_record_test.desc session_record_test.proto
- *
- */
-public class ProtobufEventSchemaTest {
-
- public static class InputDatas{
- Proto3TypesProtos.Proto3Types msg;
- Proto3TypesProtos.StructMessage subMsg1;
- Proto3TypesProtos.StructMessage subMsg2;
- Map<String, Object> map;
- Map<String, Object> subMap1;
- Map<String, Object> subMap2;
- }
-
- public static InputDatas geneInputDatas(){
- ThreadLocalRandom random = ThreadLocalRandom.current();
- Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
- Map<String, Object> map = new HashMap<>();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
- Map<String, Object> subMap1 = new HashMap<>();
- Map<String, Object> subMap2 = new HashMap<>();
-
- long int64 = random.nextLong(1, Long.MAX_VALUE);
- msgBuilder.setInt64(int64);
- map.put("int64", int64);
-
- int int32 = random.nextInt(1, Integer.MAX_VALUE);
- msgBuilder.setInt32(int32);
- map.put("int32", int32);
-
- String text = "ut8字符串";
- msgBuilder.setText(text);
- map.put("text", text);
-
- byte[] bytes = new byte[]{1, 2, 3, 4, 5};
- msgBuilder.setBytes(ByteString.copyFrom(bytes));
- map.put("bytes", bytes);
-
- int enum_val = 1;
- msgBuilder.setEnumValValue(enum_val);
- map.put("enum_val", enum_val);
-
- // subMsg start
- long id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder1.setId(id);
- subMap1.put("id", id);
-
- String name = "ut8字符串1";
- subMsgBuilder1.setName(name);
- subMap1.put("name", name);
-
- int age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder1.setAge(age);
- subMap1.put("age", age);
-
- double score = random.nextDouble(1, Integer.MAX_VALUE);
- subMsgBuilder1.setScore(score);
- subMap1.put("score", score);
-
- long optional_id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder1.setOptionalId(optional_id);
- subMap1.put("optional_id", optional_id);
-
- int optional_age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder1.setOptionalAge(optional_age);
- subMap1.put("optional_age", optional_age);
-
- id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder2.setId(id);
- subMap2.put("id", id);
-
- name = "ut8字符串1";
- subMsgBuilder2.setName(name);
- subMap2.put("name", name);
-
- age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder2.setAge(age);
- subMap2.put("age", age);
-
- score = random.nextDouble(1, Integer.MAX_VALUE);
- subMsgBuilder2.setScore(score);
- subMap2.put("score", score);
-
- optional_id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder2.setOptionalId(optional_id);
- subMap2.put("optional_id", optional_id);
-
- optional_age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder2.setOptionalAge(optional_age);
- subMap2.put("optional_age", optional_age);
-
- Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
- Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
- // subMsg end
-
- msgBuilder.setMessage(subMsg1);
- map.put("message", subMap1);
-
- long optional_int64 = random.nextLong(1, Long.MAX_VALUE);
- msgBuilder.setOptionalInt64(optional_int64);
- map.put("optional_int64", optional_int64);
-
- int optional_int32 = random.nextInt(1, Integer.MAX_VALUE);
- msgBuilder.setOptionalInt32(optional_int32);
- map.put("optional_int32", optional_int32);
-
- String optional_text = "ut8字符串";
- msgBuilder.setOptionalText(optional_text);
- map.put("optional_text", optional_text);
-
- byte[] optional_bytes = new byte[]{1, 2, 3, 4, 5};
- msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
- map.put("optional_bytes", optional_bytes);
-
- int optional_enum_val = 1;
- msgBuilder.setOptionalEnumValValue(optional_enum_val);
- map.put("optional_enum_val", optional_enum_val);
-
- msgBuilder.setOptionalMessage(subMsg2);
- map.put("optional_message", subMap2);
-
- List<Long> repeated_int64 = Arrays.asList(1L, 3L, 5L);
- msgBuilder.addAllRepeatedInt64(repeated_int64);
- map.put("repeated_int64", repeated_int64);
-
- List<Integer> repeated_int32 = Arrays.asList(1, 3, 5);
- msgBuilder.addAllRepeatedInt32(repeated_int32);
- map.put("repeated_int32", repeated_int32);
-
- msgBuilder.addAllRepeatedMessage(Arrays.asList(subMsg1, subMsg2));
- map.put("repeated_message", Arrays.asList(subMap1, subMap2));
-
- InputDatas datas = new InputDatas();
- datas.msg = msgBuilder.build();
- datas.subMsg1 = subMsg1;
- datas.subMsg2 = subMsg2;
- datas.map = map;
- datas.subMap1 = subMap1;
- datas.subMap2 = subMap2;
- return datas;
- }
-
- public static InputDatas geneInputDatasDefaultValue(){
- ThreadLocalRandom random = ThreadLocalRandom.current();
- Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
- Map<String, Object> map = new HashMap<>();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
- Map<String, Object> subMap1 = new HashMap<>();
- Map<String, Object> subMap2 = new HashMap<>();
-
- long int64 = 0;
- msgBuilder.setInt64(int64);
- map.put("int64", int64);
-
- int int32 = 0;
- msgBuilder.setInt32(int32);
- map.put("int32", int32);
-
- String text = "";
- msgBuilder.setText(text);
- map.put("text", text);
-
- byte[] bytes = new byte[]{};
- msgBuilder.setBytes(ByteString.copyFrom(bytes));
- map.put("bytes", bytes);
-
- int enum_val = 0;
- msgBuilder.setEnumValValue(enum_val);
- map.put("enum_val", enum_val);
-
- // subMsg start
- long id = 0;
- subMsgBuilder1.setId(id);
- subMap1.put("id", id);
-
- String name = "";
- subMsgBuilder1.setName(name);
- subMap1.put("name", name);
-
- int age = 0;
- subMsgBuilder1.setAge(age);
- subMap1.put("age", age);
-
- double score = 0;
- subMsgBuilder1.setScore(score);
- subMap1.put("score", score);
-
- long optional_id = 0;
- subMsgBuilder1.setOptionalId(optional_id);
- subMap1.put("optional_id", optional_id);
-
- int optional_age = 0;
- /*subMsgBuilder1.setOptionalAge(optional_age);
- subMap1.put("optional_age", optional_age);*/
-
- id = 0;
- subMsgBuilder2.setId(id);
- subMap2.put("id", id);
-
- name = "";
- subMsgBuilder2.setName(name);
- subMap2.put("name", name);
-
- age = 0;
- subMsgBuilder2.setAge(age);
- subMap2.put("age", age);
-
- score = 0;
- subMsgBuilder2.setScore(score);
- subMap2.put("score", score);
-
- optional_id = 0;
- subMsgBuilder2.setOptionalId(optional_id);
- subMap2.put("optional_id", optional_id);
-
- optional_age = 0;
- subMsgBuilder2.setOptionalAge(optional_age);
- subMap2.put("optional_age", optional_age);
-
- Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
- Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
- // subMsg end
-
- msgBuilder.setMessage(subMsg1);
- map.put("message", subMap1);
-
- long optional_int64 = 0;
- msgBuilder.setOptionalInt64(optional_int64);
- map.put("optional_int64", optional_int64);
-
- int optional_int32 = 0;
- msgBuilder.setOptionalInt32(optional_int32);
- map.put("optional_int32", optional_int32);
-
- String optional_text = "";
- msgBuilder.setOptionalText(optional_text);
- map.put("optional_text", optional_text);
-
- byte[] optional_bytes = new byte[]{};
- msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
- map.put("optional_bytes", optional_bytes);
-
- int optional_enum_val = 0;
- msgBuilder.setOptionalEnumValValue(optional_enum_val);
- map.put("optional_enum_val", optional_enum_val);
-
- msgBuilder.setOptionalMessage(subMsg2);
- map.put("optional_message", subMap2);
-
- List<Long> repeated_int64 = Arrays.asList();
- msgBuilder.addAllRepeatedInt64(repeated_int64);
- map.put("repeated_int64", repeated_int64);
-
- List<Integer> repeated_int32 = Arrays.asList();
- msgBuilder.addAllRepeatedInt32(repeated_int32);
- map.put("repeated_int32", repeated_int32);
-
- msgBuilder.addAllRepeatedMessage(Arrays.asList());
- map.put("repeated_message", Arrays.asList());
-
- InputDatas datas = new InputDatas();
- datas.msg = msgBuilder.build();
- datas.subMsg1 = subMsg1;
- datas.subMsg2 = subMsg2;
- datas.map = map;
- datas.subMap1 = subMap1;
- datas.subMap2 = subMap2;
- return datas;
- }
-
- public static InputDatas geneInputDatasUsePartialField(){
- ThreadLocalRandom random = ThreadLocalRandom.current();
- Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
- Map<String, Object> map = new HashMap<>();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
- Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
- Map<String, Object> subMap1 = new HashMap<>();
- Map<String, Object> subMap2 = new HashMap<>();
-
- /*long int64 = random.nextLong(1, Long.MAX_VALUE);
- msgBuilder.setInt64(int64);
- map.put("int64", int64);*/
-
- int int32 = random.nextInt(1, Integer.MAX_VALUE);
- msgBuilder.setInt32(int32);
- map.put("int32", int32);
-
- String text = "ut8字符串";
- msgBuilder.setText(text);
- map.put("text", text);
-
- /*byte[] bytes = new byte[]{1, 2, 3, 4, 5};
- msgBuilder.setBytes(ByteString.copyFrom(bytes));
- map.put("bytes", bytes);*/
-
- /*int enum_val = 1;
- msgBuilder.setEnumValValue(enum_val);
- map.put("enum_val", enum_val);*/
-
- // subMsg start
- long id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder1.setId(id);
- subMap1.put("id", id);
-
- String name = "ut8字符串1";
- /*subMsgBuilder1.setName(name);
- subMap1.put("name", name);*/
-
- int age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder1.setAge(age);
- subMap1.put("age", age);
-
- double score = random.nextDouble(1, Integer.MAX_VALUE);
- /*subMsgBuilder1.setScore(score);
- subMap1.put("score", score);*/
-
- long optional_id = random.nextLong(1, Long.MAX_VALUE);
- subMsgBuilder1.setOptionalId(optional_id);
- subMap1.put("optional_id", optional_id);
-
- int optional_age = random.nextInt(1, Integer.MAX_VALUE);
- /*subMsgBuilder1.setOptionalAge(optional_age);
- subMap1.put("optional_age", optional_age);*/
-
- id = random.nextLong(1, Long.MAX_VALUE);
- /*subMsgBuilder2.setId(id);
- subMap2.put("id", id);*/
-
- name = "ut8字符串1";
- subMsgBuilder2.setName(name);
- subMap2.put("name", name);
-
- age = random.nextInt(1, Integer.MAX_VALUE);
- /*subMsgBuilder2.setAge(age);
- subMap2.put("age", age);*/
-
- score = random.nextDouble(1, Integer.MAX_VALUE);
- subMsgBuilder2.setScore(score);
- subMap2.put("score", score);
-
- optional_id = random.nextLong(1, Long.MAX_VALUE);
- /*subMsgBuilder2.setOptionalId(optional_id);
- subMap2.put("optional_id", optional_id);*/
-
- optional_age = random.nextInt(1, Integer.MAX_VALUE);
- subMsgBuilder2.setOptionalAge(optional_age);
- subMap2.put("optional_age", optional_age);
-
- Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
- Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
- // subMsg end
-
- /*msgBuilder.setMessage(subMsg1);
- map.put("message", subMap1);*/
-
- long optional_int64 = random.nextLong(1, Long.MAX_VALUE);
- msgBuilder.setOptionalInt64(optional_int64);
- map.put("optional_int64", optional_int64);
-
- /*int optional_int32 = random.nextInt(1, Integer.MAX_VALUE);
- msgBuilder.setOptionalInt32(optional_int32);
- map.put("optional_int32", optional_int32);*/
-
- String optional_text = "ut8字符串";
- msgBuilder.setOptionalText(optional_text);
- map.put("optional_text", optional_text);
-
- /*byte[] optional_bytes = new byte[]{1, 2, 3, 4, 5};
- msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
- map.put("optional_bytes", optional_bytes);*/
-
- int optional_enum_val = 1;
- msgBuilder.setOptionalEnumValValue(optional_enum_val);
- map.put("optional_enum_val", optional_enum_val);
-
- msgBuilder.setOptionalMessage(subMsg2);
- map.put("optional_message", subMap2);
-
- /*List<Long> repeated_int64 = Arrays.asList(1L, 3L, 5L);
- msgBuilder.addAllRepeatedInt64(repeated_int64);
- map.put("repeated_int64", repeated_int64);*/
-
- List<Integer> repeated_int32 = Arrays.asList(1, 3, 5);
- msgBuilder.addAllRepeatedInt32(repeated_int32);
- map.put("repeated_int32", repeated_int32);
-
- msgBuilder.addAllRepeatedMessage(Arrays.asList(subMsg1, subMsg2));
- map.put("repeated_message", Arrays.asList(subMap1, subMap2));
-
- InputDatas datas = new InputDatas();
- datas.msg = msgBuilder.build();
- datas.subMsg1 = subMsg1;
- datas.subMsg2 = subMsg2;
- datas.map = map;
- datas.subMap1 = subMap1;
- datas.subMap2 = subMap2;
- return datas;
- }
-
- @Test
- public void testSerializeAndDeserialize() throws Exception{
- String path = getClass().getResource("/proto3_types.desc").getPath();
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
- InputDatas inputDatas = geneInputDatas();
-
- byte[] bytesSerByApi = inputDatas.msg.toByteArray();
-
- ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
- byte[] bytesSer = serializer.serialize(inputDatas.map);
-
- System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
- assertArrayEquals(bytesSerByApi, bytesSer);
-
- MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
- Map<String, Object> rstMap = messageConverter.converter(bytesSer);
-
- assertTrue(objEquals(inputDatas.map, rstMap, false), () -> "\n" + inputDatas.map.toString() + "\n" + rstMap.toString());
- System.out.println(inputDatas.map.toString());
- System.out.println(rstMap.toString());
- System.out.println(JSON.toJSONString(inputDatas.map));
- System.out.println(JSON.toJSONString(rstMap));
-
- System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
- }
-
- @Test
- public void testSerializeAndDeserializeDefaultValue() throws Exception{
- String path = getClass().getResource("/proto3_types.desc").getPath();
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
- InputDatas inputDatas = geneInputDatasDefaultValue();
-
- byte[] bytesSerByApi = inputDatas.msg.toByteArray();
-
- ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
- byte[] bytesSer = serializer.serialize(inputDatas.map);
-
- System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
- assertArrayEquals(bytesSerByApi, bytesSer);
-
- MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
- Map<String, Object> rstMap = messageConverter.converter(bytesSer);
- messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), true);
- Map<String, Object> rstMapEmitDefaultValue = messageConverter.converter(bytesSer);
-
- // message不是null就输出, 数组长度大于0才输出, optional设置值就输出, optional bytes长度为0也输出
- System.out.println(inputDatas.map.toString());
- System.out.println(rstMap.toString());
- System.out.println(rstMapEmitDefaultValue.toString());
- System.out.println(JSON.toJSONString(inputDatas.map));
- System.out.println(JSON.toJSONString(rstMap));
- System.out.println(JSON.toJSONString(rstMapEmitDefaultValue));
-
- System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
- }
-
- @Test
- public void testSerializeAndDeserializeUsePartialField() throws Exception{
- String path = getClass().getResource("/proto3_types.desc").getPath();
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
- InputDatas inputDatas = geneInputDatasUsePartialField();
-
- byte[] bytesSerByApi = inputDatas.msg.toByteArray();
-
- ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
- byte[] bytesSer = serializer.serialize(inputDatas.map);
- System.out.println(Base64.getEncoder().encodeToString(bytesSer));
-
- System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
- assertArrayEquals(bytesSerByApi, bytesSer);
-
- MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
- Map<String, Object> rstMap = messageConverter.converter(bytesSer);
-
- assertTrue(objEquals(inputDatas.map, rstMap, false), () -> "\n" + inputDatas.map.toString() + "\n" + rstMap.toString());
- System.out.println(inputDatas.map.toString());
- System.out.println(rstMap.toString());
- System.out.println(JSON.toJSONString(inputDatas.map));
- System.out.println(JSON.toJSONString(rstMap));
-
- System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
- }
-
- @Test
- public void testSerializeAndDeserializeSessionRecord() throws Exception{
- String path = getClass().getResource("/session_record_test.desc").getPath();
- Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"SessionRecord");
- String json = "{\"recv_time\": 1704350600, \"log_id\": 185826449998479360, \"decoded_as\": \"BASE\", \"session_id\": 290502878495441820, \"start_timestamp_ms\": 1704350566378, \"end_timestamp_ms\": 1704350570816, \"duration_ms\": 4438, \"tcp_handshake_latency_ms\": 1105, \"ingestion_time\": 1704350600, \"processing_time\": 1704350600, \"device_id\": \"21426003\", \"out_link_id\": 65535, \"in_link_id\": 65535, \"device_tag\": \"{\\\"tags\\\":[{\\\"tag\\\":\\\"data_center\\\",\\\"value\\\":\\\"center-xxg-9140\\\"},{\\\"tag\\\":\\\"device_group\\\",\\\"value\\\":\\\"group-xxg-9140\\\"}]}\", \"data_center\": \"center-xxg-9140\", \"device_group\": \"group-xxg-9140\", \"sled_ip\": \"192.168.40.81\", \"address_type\": 4, \"vsys_id\": 1, \"t_vsys_id\": 1, \"flags\": 24592, \"flags_identify_info\": \"[1,1,2]\", \"statistics_rule_list\": [406583], \"client_ip\": \"192.56.151.80\", \"client_port\": 62241, \"client_os_desc\": \"Windows\", \"client_geolocation\": \"\\u7f8e\\u56fd.Unknown.Unknown..\", \"server_ip\": \"192.56.222.93\", \"server_port\": 14454, \"server_os_desc\": \"Linux\", \"server_geolocation\": \"\\u7f8e\\u56fd.Unknown.Unknown..\", \"ip_protocol\": \"tcp\", \"decoded_path\": \"ETHERNET.IPv4.TCP\", \"sent_pkts\": 4, \"received_pkts\": 5, \"sent_bytes\": 246, \"received_bytes\": 1809, \"tcp_rtt_ms\": 128, \"tcp_client_isn\": 568305009, \"tcp_server_isn\": 4027331180, \"in_src_mac\": \"a2:fa:dc:56:c7:b3\", \"out_src_mac\": \"48:73:97:96:38:20\", \"in_dest_mac\": \"48:73:97:96:38:20\", \"out_dest_mac\": \"a2:fa:dc:56:c7:b3\"}";
- Map<String, Object> map = JSON.parseObject(json);
-
- ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
- byte[] bytesSer = serializer.serialize(map);
- System.out.println(Base64.getEncoder().encodeToString(bytesSer));
-
- System.out.println(String.format("my ser bytes size:%d", bytesSer.length));
-
- MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
- Map<String, Object> rstMap = messageConverter.converter(bytesSer);
-
- assertTrue(objEquals(map, rstMap, true), () -> "\n" + JSON.toJSONString(map) + "\n" + JSON.toJSONString(rstMap));
- System.out.println(map.toString());
- System.out.println(rstMap.toString());
- System.out.println(JSON.toJSONString(new TreeMap<>(map)));
- System.out.println(JSON.toJSONString(new TreeMap<>(rstMap)));
-
- System.out.println(JSON.toJSONString(new TreeMap<>(map)).equals(JSON.toJSONString(new TreeMap<>(rstMap))));
- }
-
- @Test
- public void testArrayInstance() throws Exception{
- Object bytes = new byte[]{1, 2, 3, 4, 5};
- Object ints = new int[]{1, 2, 3, 4, 5};
-
- System.out.println(bytes.getClass().isArray());
- System.out.println(bytes instanceof byte[]);
- System.out.println(bytes instanceof int[]);
- System.out.println(ints.getClass().isArray());
- System.out.println(ints instanceof byte[]);
- System.out.println(ints instanceof int[]);
- }
-
- private boolean objEquals(Object value1, Object value2, boolean numConvert){
- if(value1 == null){
- if(value1 != value2){
- return false;
- }
- }else if(value2 == null){
- return false;
- }else if(value1 instanceof Map){
- if(!mapEquals((Map<String, Object>) value1, (Map<String, Object>) value2, numConvert)){
- return false;
- }
- }else if(value1 instanceof List){
- if(!listEquals((List< Object>) value1, (List< Object>) value2, numConvert)){
- return false;
- }
- }else if(value1 instanceof byte[]){
- if(!Arrays.equals((byte[]) value1, (byte[]) value2)){
- return false;
- }
- }
- else{
- if(value1.getClass() != value2.getClass() || !value1.equals(value2)){
- if(numConvert && value1 instanceof Number && value2 instanceof Number && ((Number) value1).longValue() == ((Number) value2).longValue()){
-
- }else{
- return false;
- }
- }
- }
- return true;
- }
- private boolean mapEquals(Map<String, Object> map1, Map<String, Object> map2, boolean numConvert){
- if(map1.size() != map2.size()){
- return false;
- }
-
- for (Map.Entry<String, Object> entry : map1.entrySet()) {
- Object value1 = entry.getValue();
- Object value2 = map2.get(entry.getKey());
- if(!objEquals(value1, value2, numConvert)){
- return false;
- }
- }
-
- return true;
- }
-
- private boolean listEquals(List< Object> list1, List< Object> list2, boolean numConvert){
- if(list1.size() != list2.size()){
- return false;
- }
-
- for (int i = 0; i < list1.size(); i++) {
- if(!objEquals(list1.get(i), list2.get(i), numConvert)){
- return false;
- }
- }
-
- return true;
- }
-}
+package com.geedgenetworks.formats.protobuf;
+
+import com.alibaba.fastjson2.JSON;
+import com.geedgenetworks.shaded.com.google.protobuf.ByteString;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
+import org.apache.flink.util.Preconditions;
+import org.apache.kafka.common.record.CompressionType;
+import org.apache.kafka.common.utils.ByteBufferOutputStream;
+import org.junit.jupiter.api.Test;
+import com.geedgenetworks.formats.protobuf.SchemaConverters.MessageConverter;
+
+import java.io.FileInputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * protoc --descriptor_set_out=proto3_types.desc --java_out=./ proto3_types.proto
+ * protoc --descriptor_set_out=session_record_test.desc session_record_test.proto
+ *
+ */
+public class ProtobufEventSchemaTest {
+
+ public static class InputDatas{
+ Proto3TypesProtos.Proto3Types msg;
+ Proto3TypesProtos.StructMessage subMsg1;
+ Proto3TypesProtos.StructMessage subMsg2;
+ Map<String, Object> map;
+ Map<String, Object> subMap1;
+ Map<String, Object> subMap2;
+ }
+
+ public static InputDatas geneInputDatas(){
+ ThreadLocalRandom random = ThreadLocalRandom.current();
+ Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
+ Map<String, Object> map = new HashMap<>();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
+ Map<String, Object> subMap1 = new HashMap<>();
+ Map<String, Object> subMap2 = new HashMap<>();
+
+ long int64 = random.nextLong(1, Long.MAX_VALUE);
+ msgBuilder.setInt64(int64);
+ map.put("int64", int64);
+
+ int int32 = random.nextInt(1, Integer.MAX_VALUE);
+ msgBuilder.setInt32(int32);
+ map.put("int32", int32);
+
+ String text = "ut8字符串";
+ msgBuilder.setText(text);
+ map.put("text", text);
+
+ byte[] bytes = new byte[]{1, 2, 3, 4, 5};
+ msgBuilder.setBytes(ByteString.copyFrom(bytes));
+ map.put("bytes", bytes);
+
+ int enum_val = 1;
+ msgBuilder.setEnumValValue(enum_val);
+ map.put("enum_val", enum_val);
+
+ // subMsg start
+ long id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder1.setId(id);
+ subMap1.put("id", id);
+
+ String name = "ut8字符串1";
+ subMsgBuilder1.setName(name);
+ subMap1.put("name", name);
+
+ int age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder1.setAge(age);
+ subMap1.put("age", age);
+
+ double score = random.nextDouble(1, Integer.MAX_VALUE);
+ subMsgBuilder1.setScore(score);
+ subMap1.put("score", score);
+
+ long optional_id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder1.setOptionalId(optional_id);
+ subMap1.put("optional_id", optional_id);
+
+ int optional_age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder1.setOptionalAge(optional_age);
+ subMap1.put("optional_age", optional_age);
+
+ id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder2.setId(id);
+ subMap2.put("id", id);
+
+ name = "ut8字符串1";
+ subMsgBuilder2.setName(name);
+ subMap2.put("name", name);
+
+ age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder2.setAge(age);
+ subMap2.put("age", age);
+
+ score = random.nextDouble(1, Integer.MAX_VALUE);
+ subMsgBuilder2.setScore(score);
+ subMap2.put("score", score);
+
+ optional_id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder2.setOptionalId(optional_id);
+ subMap2.put("optional_id", optional_id);
+
+ optional_age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder2.setOptionalAge(optional_age);
+ subMap2.put("optional_age", optional_age);
+
+ Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
+ Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
+ // subMsg end
+
+ msgBuilder.setMessage(subMsg1);
+ map.put("message", subMap1);
+
+ long optional_int64 = random.nextLong(1, Long.MAX_VALUE);
+ msgBuilder.setOptionalInt64(optional_int64);
+ map.put("optional_int64", optional_int64);
+
+ int optional_int32 = random.nextInt(1, Integer.MAX_VALUE);
+ msgBuilder.setOptionalInt32(optional_int32);
+ map.put("optional_int32", optional_int32);
+
+ String optional_text = "ut8字符串";
+ msgBuilder.setOptionalText(optional_text);
+ map.put("optional_text", optional_text);
+
+ byte[] optional_bytes = new byte[]{1, 2, 3, 4, 5};
+ msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
+ map.put("optional_bytes", optional_bytes);
+
+ int optional_enum_val = 1;
+ msgBuilder.setOptionalEnumValValue(optional_enum_val);
+ map.put("optional_enum_val", optional_enum_val);
+
+ msgBuilder.setOptionalMessage(subMsg2);
+ map.put("optional_message", subMap2);
+
+ List<Long> repeated_int64 = Arrays.asList(1L, 3L, 5L);
+ msgBuilder.addAllRepeatedInt64(repeated_int64);
+ map.put("repeated_int64", repeated_int64);
+
+ List<Integer> repeated_int32 = Arrays.asList(1, 3, 5);
+ msgBuilder.addAllRepeatedInt32(repeated_int32);
+ map.put("repeated_int32", repeated_int32);
+
+ msgBuilder.addAllRepeatedMessage(Arrays.asList(subMsg1, subMsg2));
+ map.put("repeated_message", Arrays.asList(subMap1, subMap2));
+
+ InputDatas datas = new InputDatas();
+ datas.msg = msgBuilder.build();
+ datas.subMsg1 = subMsg1;
+ datas.subMsg2 = subMsg2;
+ datas.map = map;
+ datas.subMap1 = subMap1;
+ datas.subMap2 = subMap2;
+ return datas;
+ }
+
+ public static InputDatas geneInputDatasDefaultValue(){
+ ThreadLocalRandom random = ThreadLocalRandom.current();
+ Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
+ Map<String, Object> map = new HashMap<>();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
+ Map<String, Object> subMap1 = new HashMap<>();
+ Map<String, Object> subMap2 = new HashMap<>();
+
+ long int64 = 0;
+ msgBuilder.setInt64(int64);
+ map.put("int64", int64);
+
+ int int32 = 0;
+ msgBuilder.setInt32(int32);
+ map.put("int32", int32);
+
+ String text = "";
+ msgBuilder.setText(text);
+ map.put("text", text);
+
+ byte[] bytes = new byte[]{};
+ msgBuilder.setBytes(ByteString.copyFrom(bytes));
+ map.put("bytes", bytes);
+
+ int enum_val = 0;
+ msgBuilder.setEnumValValue(enum_val);
+ map.put("enum_val", enum_val);
+
+ // subMsg start
+ long id = 0;
+ subMsgBuilder1.setId(id);
+ subMap1.put("id", id);
+
+ String name = "";
+ subMsgBuilder1.setName(name);
+ subMap1.put("name", name);
+
+ int age = 0;
+ subMsgBuilder1.setAge(age);
+ subMap1.put("age", age);
+
+ double score = 0;
+ subMsgBuilder1.setScore(score);
+ subMap1.put("score", score);
+
+ long optional_id = 0;
+ subMsgBuilder1.setOptionalId(optional_id);
+ subMap1.put("optional_id", optional_id);
+
+ int optional_age = 0;
+ /*subMsgBuilder1.setOptionalAge(optional_age);
+ subMap1.put("optional_age", optional_age);*/
+
+ id = 0;
+ subMsgBuilder2.setId(id);
+ subMap2.put("id", id);
+
+ name = "";
+ subMsgBuilder2.setName(name);
+ subMap2.put("name", name);
+
+ age = 0;
+ subMsgBuilder2.setAge(age);
+ subMap2.put("age", age);
+
+ score = 0;
+ subMsgBuilder2.setScore(score);
+ subMap2.put("score", score);
+
+ optional_id = 0;
+ subMsgBuilder2.setOptionalId(optional_id);
+ subMap2.put("optional_id", optional_id);
+
+ optional_age = 0;
+ subMsgBuilder2.setOptionalAge(optional_age);
+ subMap2.put("optional_age", optional_age);
+
+ Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
+ Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
+ // subMsg end
+
+ msgBuilder.setMessage(subMsg1);
+ map.put("message", subMap1);
+
+ long optional_int64 = 0;
+ msgBuilder.setOptionalInt64(optional_int64);
+ map.put("optional_int64", optional_int64);
+
+ int optional_int32 = 0;
+ msgBuilder.setOptionalInt32(optional_int32);
+ map.put("optional_int32", optional_int32);
+
+ String optional_text = "";
+ msgBuilder.setOptionalText(optional_text);
+ map.put("optional_text", optional_text);
+
+ byte[] optional_bytes = new byte[]{};
+ msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
+ map.put("optional_bytes", optional_bytes);
+
+ int optional_enum_val = 0;
+ msgBuilder.setOptionalEnumValValue(optional_enum_val);
+ map.put("optional_enum_val", optional_enum_val);
+
+ msgBuilder.setOptionalMessage(subMsg2);
+ map.put("optional_message", subMap2);
+
+ List<Long> repeated_int64 = Arrays.asList();
+ msgBuilder.addAllRepeatedInt64(repeated_int64);
+ map.put("repeated_int64", repeated_int64);
+
+ List<Integer> repeated_int32 = Arrays.asList();
+ msgBuilder.addAllRepeatedInt32(repeated_int32);
+ map.put("repeated_int32", repeated_int32);
+
+ msgBuilder.addAllRepeatedMessage(Arrays.asList());
+ map.put("repeated_message", Arrays.asList());
+
+ InputDatas datas = new InputDatas();
+ datas.msg = msgBuilder.build();
+ datas.subMsg1 = subMsg1;
+ datas.subMsg2 = subMsg2;
+ datas.map = map;
+ datas.subMap1 = subMap1;
+ datas.subMap2 = subMap2;
+ return datas;
+ }
+
+ public static InputDatas geneInputDatasUsePartialField(){
+ ThreadLocalRandom random = ThreadLocalRandom.current();
+ Proto3TypesProtos.Proto3Types.Builder msgBuilder = Proto3TypesProtos.Proto3Types.newBuilder();
+ Map<String, Object> map = new HashMap<>();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder1 = Proto3TypesProtos.StructMessage.newBuilder();
+ Proto3TypesProtos.StructMessage.Builder subMsgBuilder2 = Proto3TypesProtos.StructMessage.newBuilder();
+ Map<String, Object> subMap1 = new HashMap<>();
+ Map<String, Object> subMap2 = new HashMap<>();
+
+ /*long int64 = random.nextLong(1, Long.MAX_VALUE);
+ msgBuilder.setInt64(int64);
+ map.put("int64", int64);*/
+
+ int int32 = random.nextInt(1, Integer.MAX_VALUE);
+ msgBuilder.setInt32(int32);
+ map.put("int32", int32);
+
+ String text = "ut8字符串";
+ msgBuilder.setText(text);
+ map.put("text", text);
+
+ /*byte[] bytes = new byte[]{1, 2, 3, 4, 5};
+ msgBuilder.setBytes(ByteString.copyFrom(bytes));
+ map.put("bytes", bytes);*/
+
+ /*int enum_val = 1;
+ msgBuilder.setEnumValValue(enum_val);
+ map.put("enum_val", enum_val);*/
+
+ // subMsg start
+ long id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder1.setId(id);
+ subMap1.put("id", id);
+
+ String name = "ut8字符串1";
+ /*subMsgBuilder1.setName(name);
+ subMap1.put("name", name);*/
+
+ int age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder1.setAge(age);
+ subMap1.put("age", age);
+
+ double score = random.nextDouble(1, Integer.MAX_VALUE);
+ /*subMsgBuilder1.setScore(score);
+ subMap1.put("score", score);*/
+
+ long optional_id = random.nextLong(1, Long.MAX_VALUE);
+ subMsgBuilder1.setOptionalId(optional_id);
+ subMap1.put("optional_id", optional_id);
+
+ int optional_age = random.nextInt(1, Integer.MAX_VALUE);
+ /*subMsgBuilder1.setOptionalAge(optional_age);
+ subMap1.put("optional_age", optional_age);*/
+
+ id = random.nextLong(1, Long.MAX_VALUE);
+ /*subMsgBuilder2.setId(id);
+ subMap2.put("id", id);*/
+
+ name = "ut8字符串1";
+ subMsgBuilder2.setName(name);
+ subMap2.put("name", name);
+
+ age = random.nextInt(1, Integer.MAX_VALUE);
+ /*subMsgBuilder2.setAge(age);
+ subMap2.put("age", age);*/
+
+ score = random.nextDouble(1, Integer.MAX_VALUE);
+ subMsgBuilder2.setScore(score);
+ subMap2.put("score", score);
+
+ optional_id = random.nextLong(1, Long.MAX_VALUE);
+ /*subMsgBuilder2.setOptionalId(optional_id);
+ subMap2.put("optional_id", optional_id);*/
+
+ optional_age = random.nextInt(1, Integer.MAX_VALUE);
+ subMsgBuilder2.setOptionalAge(optional_age);
+ subMap2.put("optional_age", optional_age);
+
+ Proto3TypesProtos.StructMessage subMsg1 = subMsgBuilder1.build();
+ Proto3TypesProtos.StructMessage subMsg2 = subMsgBuilder2.build();
+ // subMsg end
+
+ /*msgBuilder.setMessage(subMsg1);
+ map.put("message", subMap1);*/
+
+ long optional_int64 = random.nextLong(1, Long.MAX_VALUE);
+ msgBuilder.setOptionalInt64(optional_int64);
+ map.put("optional_int64", optional_int64);
+
+ /*int optional_int32 = random.nextInt(1, Integer.MAX_VALUE);
+ msgBuilder.setOptionalInt32(optional_int32);
+ map.put("optional_int32", optional_int32);*/
+
+ String optional_text = "ut8字符串";
+ msgBuilder.setOptionalText(optional_text);
+ map.put("optional_text", optional_text);
+
+ /*byte[] optional_bytes = new byte[]{1, 2, 3, 4, 5};
+ msgBuilder.setOptionalBytes(ByteString.copyFrom(optional_bytes));
+ map.put("optional_bytes", optional_bytes);*/
+
+ int optional_enum_val = 1;
+ msgBuilder.setOptionalEnumValValue(optional_enum_val);
+ map.put("optional_enum_val", optional_enum_val);
+
+ msgBuilder.setOptionalMessage(subMsg2);
+ map.put("optional_message", subMap2);
+
+ /*List<Long> repeated_int64 = Arrays.asList(1L, 3L, 5L);
+ msgBuilder.addAllRepeatedInt64(repeated_int64);
+ map.put("repeated_int64", repeated_int64);*/
+
+ List<Integer> repeated_int32 = Arrays.asList(1, 3, 5);
+ msgBuilder.addAllRepeatedInt32(repeated_int32);
+ map.put("repeated_int32", repeated_int32);
+
+ msgBuilder.addAllRepeatedMessage(Arrays.asList(subMsg1, subMsg2));
+ map.put("repeated_message", Arrays.asList(subMap1, subMap2));
+
+ InputDatas datas = new InputDatas();
+ datas.msg = msgBuilder.build();
+ datas.subMsg1 = subMsg1;
+ datas.subMsg2 = subMsg2;
+ datas.map = map;
+ datas.subMap1 = subMap1;
+ datas.subMap2 = subMap2;
+ return datas;
+ }
+
+ @Test
+ public void testSerializeAndDeserialize() throws Exception{
+ String path = getClass().getResource("/proto3_types.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
+ InputDatas inputDatas = geneInputDatas();
+
+ byte[] bytesSerByApi = inputDatas.msg.toByteArray();
+
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+ byte[] bytesSer = serializer.serialize(inputDatas.map);
+
+ System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
+ assertArrayEquals(bytesSerByApi, bytesSer);
+
+ MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+ Map<String, Object> rstMap = messageConverter.converter(bytesSer);
+
+ assertTrue(objEquals(inputDatas.map, rstMap, false), () -> "\n" + inputDatas.map.toString() + "\n" + rstMap.toString());
+ System.out.println(inputDatas.map.toString());
+ System.out.println(rstMap.toString());
+ System.out.println(JSON.toJSONString(inputDatas.map));
+ System.out.println(JSON.toJSONString(rstMap));
+
+ System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
+ }
+
+ @Test
+ public void testSerializeAndDeserializeDefaultValue() throws Exception{
+ String path = getClass().getResource("/proto3_types.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
+ InputDatas inputDatas = geneInputDatasDefaultValue();
+
+ byte[] bytesSerByApi = inputDatas.msg.toByteArray();
+
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+ byte[] bytesSer = serializer.serialize(inputDatas.map);
+
+ System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
+ assertArrayEquals(bytesSerByApi, bytesSer);
+
+ MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+ Map<String, Object> rstMap = messageConverter.converter(bytesSer);
+ messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), true);
+ Map<String, Object> rstMapEmitDefaultValue = messageConverter.converter(bytesSer);
+
+ // message不是null就输出, 数组长度大于0才输出, optional设置值就输出, optional bytes长度为0也输出
+ System.out.println(inputDatas.map.toString());
+ System.out.println(rstMap.toString());
+ System.out.println(rstMapEmitDefaultValue.toString());
+ System.out.println(JSON.toJSONString(inputDatas.map));
+ System.out.println(JSON.toJSONString(rstMap));
+ System.out.println(JSON.toJSONString(rstMapEmitDefaultValue));
+
+ System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
+ }
+
+ @Test
+ public void testSerializeAndDeserializeUsePartialField() throws Exception{
+ String path = getClass().getResource("/proto3_types.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"Proto3Types");
+ InputDatas inputDatas = geneInputDatasUsePartialField();
+
+ byte[] bytesSerByApi = inputDatas.msg.toByteArray();
+
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+ byte[] bytesSer = serializer.serialize(inputDatas.map);
+ System.out.println(Base64.getEncoder().encodeToString(bytesSer));
+
+ System.out.println(String.format("built-in ser bytes size:%d\nmy ser bytes size:%d", bytesSerByApi.length, bytesSer.length));
+ assertArrayEquals(bytesSerByApi, bytesSer);
+
+ MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+ Map<String, Object> rstMap = messageConverter.converter(bytesSer);
+
+ assertTrue(objEquals(inputDatas.map, rstMap, false), () -> "\n" + inputDatas.map.toString() + "\n" + rstMap.toString());
+ System.out.println(inputDatas.map.toString());
+ System.out.println(rstMap.toString());
+ System.out.println(JSON.toJSONString(inputDatas.map));
+ System.out.println(JSON.toJSONString(rstMap));
+
+ System.out.println(JSON.toJSONString(inputDatas.map).equals(JSON.toJSONString(rstMap)));
+ }
+
+ @Test
+ public void testSerializeAndDeserializeSessionRecord() throws Exception{
+ String path = getClass().getResource("/session_record_test.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"SessionRecord");
+ String json = "{\"recv_time\": 1704350600, \"log_id\": 185826449998479360, \"decoded_as\": \"BASE\", \"session_id\": 290502878495441820, \"start_timestamp_ms\": 1704350566378, \"end_timestamp_ms\": 1704350570816, \"duration_ms\": 4438, \"tcp_handshake_latency_ms\": 1105, \"ingestion_time\": 1704350600, \"processing_time\": 1704350600, \"device_id\": \"21426003\", \"out_link_id\": 65535, \"in_link_id\": 65535, \"device_tag\": \"{\\\"tags\\\":[{\\\"tag\\\":\\\"data_center\\\",\\\"value\\\":\\\"center-xxg-9140\\\"},{\\\"tag\\\":\\\"device_group\\\",\\\"value\\\":\\\"group-xxg-9140\\\"}]}\", \"data_center\": \"center-xxg-9140\", \"device_group\": \"group-xxg-9140\", \"sled_ip\": \"192.168.40.81\", \"address_type\": 4, \"vsys_id\": 1, \"t_vsys_id\": 1, \"flags\": 24592, \"flags_identify_info\": \"[1,1,2]\", \"statistics_rule_list\": [406583], \"client_ip\": \"192.56.151.80\", \"client_port\": 62241, \"client_os_desc\": \"Windows\", \"client_geolocation\": \"\\u7f8e\\u56fd.Unknown.Unknown..\", \"server_ip\": \"192.56.222.93\", \"server_port\": 14454, \"server_os_desc\": \"Linux\", \"server_geolocation\": \"\\u7f8e\\u56fd.Unknown.Unknown..\", \"ip_protocol\": \"tcp\", \"decoded_path\": \"ETHERNET.IPv4.TCP\", \"sent_pkts\": 4, \"received_pkts\": 5, \"sent_bytes\": 246, \"received_bytes\": 1809, \"tcp_rtt_ms\": 128, \"tcp_client_isn\": 568305009, \"tcp_server_isn\": 4027331180, \"in_src_mac\": \"a2:fa:dc:56:c7:b3\", \"out_src_mac\": \"48:73:97:96:38:20\", \"in_dest_mac\": \"48:73:97:96:38:20\", \"out_dest_mac\": \"a2:fa:dc:56:c7:b3\"}";
+ Map<String, Object> map = JSON.parseObject(json);
+
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+ byte[] bytesSer = serializer.serialize(map);
+ System.out.println(Base64.getEncoder().encodeToString(bytesSer));
+
+ System.out.println(String.format("my ser bytes size:%d", bytesSer.length));
+
+ MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+ Map<String, Object> rstMap = messageConverter.converter(bytesSer);
+
+ assertTrue(objEquals(map, rstMap, true), () -> "\n" + JSON.toJSONString(map) + "\n" + JSON.toJSONString(rstMap));
+ System.out.println(map.toString());
+ System.out.println(rstMap.toString());
+ System.out.println(JSON.toJSONString(new TreeMap<>(map)));
+ System.out.println(JSON.toJSONString(new TreeMap<>(rstMap)));
+
+ System.out.println(JSON.toJSONString(new TreeMap<>(map)).equals(JSON.toJSONString(new TreeMap<>(rstMap))));
+ }
+
+
+ public static void main(String[] args) throws Exception{
+ ProtobufEventSchemaTest test = new ProtobufEventSchemaTest();
+ String path = test.getClass().getResource("/session_record_test.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"SessionRecord");
+ MessageConverter messageConverter = new MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+
+ FileInputStream inputStream = new FileInputStream("D:\\doc\\groot\\SESSION-RECORD-24-0104.json");
+ LineIterator lines = IOUtils.lineIterator(inputStream, "utf-8");
+ int count = 0;
+ long jsonBytesTotalSize = 0;
+ long protoBytesTotalSize = 0;
+ long jsonBytesMinSize = Long.MAX_VALUE;
+ long protoBytesMinSize = Long.MAX_VALUE;
+ long jsonBytesMaxSize = 0;
+ long protoBytesMaxSize = 0;
+
+ CompressionType[] compressionTypes = new CompressionType[]{
+ CompressionType.NONE, CompressionType.SNAPPY, CompressionType.LZ4, CompressionType.GZIP, CompressionType.ZSTD
+ };
+ long[][] compressionBytesSize = new long[compressionTypes.length][6];
+ for (int i = 0; i < compressionBytesSize.length; i++) {
+ compressionBytesSize[i][0] = 0;
+ compressionBytesSize[i][1] = 0;
+ compressionBytesSize[i][2] = Long.MAX_VALUE;
+ compressionBytesSize[i][3] = Long.MAX_VALUE;
+ compressionBytesSize[i][4] = 0;
+ compressionBytesSize[i][5] = 0;
+ }
+
+ while (lines.hasNext()){
+ String line = lines.next().trim();
+ if(line.isEmpty()){
+ continue;
+ }
+
+ Map<String, Object> map = JSON.parseObject(line);
+ byte[] bytesProto = serializer.serialize(map);
+ byte[] bytesJson = JSON.toJSONString(map).getBytes(StandardCharsets.UTF_8);
+ jsonBytesTotalSize += bytesJson.length;
+ protoBytesTotalSize += bytesProto.length;
+ jsonBytesMinSize = Math.min(jsonBytesMinSize, bytesJson.length);
+ protoBytesMinSize = Math.min(protoBytesMinSize, bytesProto.length);
+ jsonBytesMaxSize = Math.max(jsonBytesMaxSize, bytesJson.length);
+ protoBytesMaxSize = Math.max(protoBytesMaxSize, bytesProto.length);
+
+ Map<String, Object> rstMap = messageConverter.converter(bytesProto);
+ Preconditions.checkArgument(test.objEquals(map, rstMap, true), "\n" + JSON.toJSONString(new TreeMap<>(map)) + "\n" + JSON.toJSONString(new TreeMap<>(rstMap)));
+ Preconditions.checkArgument(JSON.toJSONString(new TreeMap<>(map)).equals(JSON.toJSONString(new TreeMap<>(rstMap))), "\n" + JSON.toJSONString(new TreeMap<>(map)) + "\n" + JSON.toJSONString(new TreeMap<>(rstMap)));
+ count++;
+
+ for (int i = 0; i < compressionTypes.length; i++) {
+ CompressionType compressionType = compressionTypes[i];
+ ByteBufferOutputStream bufferStream = new ByteBufferOutputStream(1024 * 16);
+ OutputStream outputStream = compressionType.wrapForOutput(bufferStream, (byte) 2);
+ outputStream.write(bytesJson);
+ outputStream.close();
+ int jsonCompressSize = bufferStream.position();
+
+ bufferStream = new ByteBufferOutputStream(1024 * 16);
+ outputStream = compressionType.wrapForOutput(bufferStream, (byte) 2);
+ outputStream.write(bytesProto);
+ outputStream.close();
+ int protoCompressSize = bufferStream.position();
+
+ compressionBytesSize[i][0] += jsonCompressSize;
+ compressionBytesSize[i][1] += protoCompressSize;
+ compressionBytesSize[i][2] = Math.min(compressionBytesSize[i][2], jsonCompressSize);
+ compressionBytesSize[i][3] = Math.min(compressionBytesSize[i][3], protoCompressSize);
+ compressionBytesSize[i][4] = Math.max(compressionBytesSize[i][4], jsonCompressSize);
+ compressionBytesSize[i][5] = Math.max(compressionBytesSize[i][5], protoCompressSize);
+ }
+
+ }
+ System.out.println(String.format("count:%d, jsonBytesAvgSize:%d, protoBytesAvgSize:%d, jsonBytesMinSize:%d, protoBytesMinSize:%d, jsonBytesMaxSize:%d, protoBytesMaxSize:%d", count, jsonBytesTotalSize/count, protoBytesTotalSize/count,
+ jsonBytesMinSize, protoBytesMinSize, jsonBytesMaxSize, protoBytesMaxSize));
+ for (int i = 0; i < compressionTypes.length; i++) {
+ CompressionType compressionType = compressionTypes[i];
+ System.out.println(String.format("compression(%s): count:%d, jsonBytesAvgSize:%d, protoBytesAvgSize:%d, avgRatio:%.2f, jsonBytesMinSize:%d, protoBytesMinSize:%d, minRatio:%.2f, jsonBytesMaxSize:%d, protoBytesMaxSize:%d, maxRatio:%.2f",
+ compressionType, count, compressionBytesSize[i][0]/count, compressionBytesSize[i][1]/count, (((double)compressionBytesSize[i][1])/count)/(compressionBytesSize[i][0]/count),
+ compressionBytesSize[i][2], compressionBytesSize[i][3], ((double)compressionBytesSize[i][3])/(compressionBytesSize[i][2]),
+ compressionBytesSize[i][4], compressionBytesSize[i][5], ((double)compressionBytesSize[i][5])/(compressionBytesSize[i][4])));
+ }
+ }
+
+ @Test
+ public void testArrayInstance() throws Exception{
+ Object bytes = new byte[]{1, 2, 3, 4, 5};
+ Object ints = new int[]{1, 2, 3, 4, 5};
+
+ System.out.println(bytes.getClass().isArray());
+ System.out.println(bytes instanceof byte[]);
+ System.out.println(bytes instanceof int[]);
+ System.out.println(ints.getClass().isArray());
+ System.out.println(ints instanceof byte[]);
+ System.out.println(ints instanceof int[]);
+ }
+
+ private boolean objEquals(Object value1, Object value2, boolean numConvert){
+ if(value1 == null){
+ if(value1 != value2){
+ return false;
+ }
+ }else if(value2 == null){
+ return false;
+ }else if(value1 instanceof Map){
+ if(!mapEquals((Map<String, Object>) value1, (Map<String, Object>) value2, numConvert)){
+ return false;
+ }
+ }else if(value1 instanceof List){
+ if(!listEquals((List< Object>) value1, (List< Object>) value2, numConvert)){
+ return false;
+ }
+ }else if(value1 instanceof byte[]){
+ if(!Arrays.equals((byte[]) value1, (byte[]) value2)){
+ return false;
+ }
+ }
+ else{
+ if(value1.getClass() != value2.getClass() || !value1.equals(value2)){
+ if(numConvert && value1 instanceof Number && value2 instanceof Number && ((Number) value1).longValue() == ((Number) value2).longValue()){
+
+ }else{
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ private boolean mapEquals(Map<String, Object> map1, Map<String, Object> map2, boolean numConvert){
+ if(map1.size() != map2.size()){
+ return false;
+ }
+
+ for (Map.Entry<String, Object> entry : map1.entrySet()) {
+ Object value1 = entry.getValue();
+ Object value2 = map2.get(entry.getKey());
+ if(!objEquals(value1, value2, numConvert)){
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private boolean listEquals(List< Object> list1, List< Object> list2, boolean numConvert){
+ if(list1.size() != list2.size()){
+ return false;
+ }
+
+ for (int i = 0; i < list1.size(); i++) {
+ if(!objEquals(list1.get(i), list2.get(i), numConvert)){
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufFileConverterTest.java b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufFileConverterTest.java
new file mode 100644
index 0000000..30d2843
--- /dev/null
+++ b/groot-formats/format-protobuf/src/test/java/com/geedgenetworks/formats/protobuf/ProtobufFileConverterTest.java
@@ -0,0 +1,72 @@
+package com.geedgenetworks.formats.protobuf;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.geedgenetworks.shaded.com.google.protobuf.Descriptors;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
+import org.apache.flink.shaded.guava18.com.google.common.io.Files;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.RandomAccessFile;
+import java.nio.MappedByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+public class ProtobufFileConverterTest {
+
+ public static void main(String[] args) throws Exception{
+ //json2Proto();
+ proto2Json();
+ }
+
+ public static void json2Proto() throws Exception{
+ String path = ProtobufFileConverterTest.class.getResource("/session_record_test.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"SessionRecord");
+ ProtobufSerializer serializer = new ProtobufSerializer(descriptor);
+
+ String filePath = "D:\\doc\\groot\\SESSION-RECORD-24-0108.proto";
+ RandomAccessFile raf = new RandomAccessFile(filePath, "rw");
+ try(FileInputStream inputStream = new FileInputStream("D:\\doc\\groot\\SESSION-RECORD-24-0108.json")){
+ LineIterator lines = IOUtils.lineIterator(inputStream, "utf-8");
+ while (lines.hasNext()){
+ String line = lines.next().trim();
+ if(line.isEmpty()){
+ continue;
+ }
+ JSONObject map = JSON.parseObject(line);
+ byte[] bytes = serializer.serialize(map);
+ raf.writeInt(bytes.length);
+ raf.write(bytes);
+ }
+ }
+ raf.close();
+ }
+
+ public static void proto2Json() throws Exception{
+ String path = ProtobufFileConverterTest.class.getResource("/session_record_test.desc").getPath();
+ Descriptors.Descriptor descriptor = ProtobufUtils.buildDescriptor(ProtobufUtils.readDescriptorFileContent(path),"SessionRecord");
+ SchemaConverters.MessageConverter messageConverter = new SchemaConverters.MessageConverter(descriptor, SchemaConverters.toStructType(descriptor), false);
+
+ RandomAccessFile raf = new RandomAccessFile("D:\\doc\\groot\\SESSION-RECORD-24-0108-covert.json", "rw");
+ String filePath = "D:\\doc\\groot\\SESSION-RECORD-24-0108.proto";
+ MappedByteBuffer byteBuffer = Files.map(new File(filePath));
+
+ int limit = byteBuffer.limit();
+ int size;
+ int read = 0;
+ while (read < limit){
+ size = byteBuffer.getInt();
+ read += size + 4;
+ byte[] bytes = new byte[size];
+ byteBuffer.get(bytes, 0, size);
+ Map<String, Object> map = messageConverter.converter(bytes);
+ raf.write(JSON.toJSONString(map).getBytes(StandardCharsets.UTF_8));
+ raf.write('\n');
+ }
+
+ raf.close();
+ }
+}