├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main └── java │ └── com │ └── fengfshao │ └── dynamicproto │ └── DynamicProtoBuilder.java └── test ├── java └── com │ └── fengfshao │ └── dynamicproto │ ├── DynamicProtoBuilderTest.java │ └── pb3 │ ├── MultiplePerson.java │ ├── NestedPerson.java │ ├── SimplePerson.java │ └── SimplePersonV2.java └── resources ├── multiple_person.proto ├── nested_person.proto ├── simple_person.proto └── simple_personv2.proto /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | target/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 fengfshao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 项目说明 2 | 3 | 运行时动态构建protobuf message的一种方案,无需protoc编译出源代码,可由`.proto`协议直接生成Message及字节数组。
4 | > 在与下游使用protobuf协议交互的数据处理场景中,动态构建pb+配置远程化, 5 | > 可以提高程序的灵活性,避免字段变更时的代码改动与重新编译部署。 6 | 7 | ## 使用示例 8 | ```java 9 | public class Demo { 10 | public static void main(String[] args) { 11 | 12 | // 注册proto协议 13 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 14 | Thread.currentThread().getContextClassLoader() 15 | .getResource("simple_person.proto").openStream(), "simple_person.proto"); 16 | 17 | // 准备要填充的数据 18 | Map fieldValues = new HashMap<>(); 19 | fieldValues.put("id", 1); 20 | fieldValues.put("name", "jihite"); 21 | fieldValues.put("email", "jihite@jihite.com"); 22 | fieldValues.put("address", Arrays.asList("address1", "address2", "address3")); 23 | 24 | // 生成Message 25 | Message message = DynamicProtoBuilder 26 | .buildMessage("simple_person.proto", "SimplePersonMessage", fieldValues); 27 | byte[] data = message.toByteArray(); 28 | } 29 | } 30 | ``` 31 | 更多示例见单元测试 32 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.fengfshao 8 | dynamic-proto 9 | 1.1-SNAPSHOT 10 | 11 | 12 | 13 | 14 | junit 15 | junit 16 | 4.12 17 | test 18 | 19 | 20 | 21 | com.google.protobuf 22 | protobuf-java 23 | 3.17.0 24 | provided 25 | 26 | 27 | 28 | com.github.os72 29 | protobuf-dynamic 30 | 1.0.1 31 | 32 | 33 | 34 | io.protostuff 35 | protostuff-parser 36 | 2.2.27 37 | 38 | 39 | 40 | 41 | 42 | 8 43 | 8 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-shade-plugin 52 | 3.2.4 53 | 54 | 55 | package 56 | 57 | shade 58 | 59 | 60 | true 61 | 62 | 63 | com.google.common 64 | shaded.dp.com.google.common 65 | 66 | 67 | com.google.inject 68 | shaded.dp.com.google.inject 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | com.github.igor-petruk.protobuf 77 | protobuf-maven-plugin 78 | 0.6.5 79 | 80 | true 81 | 82 | 83 | ${project.basedir}/src/test/resources 84 | 85 | 86 | /usr/local/bin/protoc3 87 | ${project.basedir}/src/test/java 88 | false 89 | 90 | 91 | 92 | process-test-sources 93 | 94 | run 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /src/main/java/com/fengfshao/dynamicproto/DynamicProtoBuilder.java: -------------------------------------------------------------------------------- 1 | package com.fengfshao.dynamicproto; 2 | 3 | import com.github.os72.protobuf.dynamic.DynamicSchema; 4 | import com.github.os72.protobuf.dynamic.EnumDefinition; 5 | import com.github.os72.protobuf.dynamic.MessageDefinition; 6 | import com.github.os72.protobuf.dynamic.MessageDefinition.Builder; 7 | import com.google.inject.Guice; 8 | import com.google.inject.Injector; 9 | import com.google.protobuf.Descriptors.Descriptor; 10 | import com.google.protobuf.Descriptors.FieldDescriptor; 11 | import com.google.protobuf.DynamicMessage; 12 | import io.protostuff.compiler.ParserModule; 13 | import io.protostuff.compiler.model.Enum; 14 | import io.protostuff.compiler.model.Field; 15 | import io.protostuff.compiler.model.Message; 16 | import io.protostuff.compiler.parser.FileReader; 17 | import io.protostuff.compiler.parser.Importer; 18 | import io.protostuff.compiler.parser.ProtoContext; 19 | import org.antlr.v4.runtime.CharStream; 20 | import org.antlr.v4.runtime.CharStreams; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | 24 | import java.io.ByteArrayInputStream; 25 | import java.io.InputStream; 26 | import java.util.List; 27 | import java.util.Map; 28 | import java.util.Objects; 29 | import java.util.concurrent.ConcurrentHashMap; 30 | 31 | /** 32 | * 运行时动态构建pb message的一种方案,无需任何protoc编译
33 | * 34 | *
 35 |  * 示例,对如下proto协议:
 36 |  * message PersonMessage {
 37 |  *  int32 id = 1;
 38 |  *  string name = 2;
 39 |  *  string email = 3;
 40 |  *  repeated string address = 4;
 41 |  * }
 42 |  *
 43 |  * 通过如下方式,可构造对应的DynamicMessage,得到对应的字节数组
 44 |  *
 45 |  * Map fieldValues = new HashMap<>();
 46 |  * fieldValues.put("id", 1);
 47 |  * fieldValues.put("name", "jihite");
 48 |  * fieldValues.put("email", "jihite@jihite.com");
 49 |  * fieldValues.put("address",Arrays.asList("address1", "address2"));
 50 |  *
 51 |  * Message dynamicMessage = DynamicProtoBuilder
 52 |  *            .buildMessage("person.proto","PersonMessage",fieldValues);
 53 |  * 
54 | * 55 | * @author fengfshao 56 | */ 57 | @SuppressWarnings("unchecked") 58 | public class DynamicProtoBuilder { 59 | 60 | private static final Logger LOGGER = LoggerFactory.getLogger(DynamicProtoBuilder.class); 61 | 62 | private static class InputStreamReader implements FileReader { 63 | 64 | private final InputStream in; 65 | 66 | public InputStreamReader(InputStream in) { 67 | this.in = in; 68 | } 69 | 70 | @Override 71 | public CharStream read(String name) { 72 | try { 73 | return CharStreams.fromStream(in); 74 | } catch (Exception e) { 75 | LOGGER.error("Could not read {}", name, e); 76 | } 77 | return null; 78 | } 79 | } 80 | 81 | public static class ProtoHolder { 82 | public static final ConcurrentHashMap cache = new ConcurrentHashMap<>(); 83 | 84 | public static void registerOrUpdate(byte[] protoBytes, String protoFileName) 85 | throws Exception { 86 | InputStream protoInputStream = new ByteArrayInputStream(protoBytes); 87 | DynamicSchema schema = parseProtoFile(protoInputStream); 88 | cache.put(protoFileName, schema); 89 | } 90 | 91 | public static void registerOrUpdate(InputStream protoInputStream, String protoFileName) 92 | throws Exception { 93 | DynamicSchema schema = parseProtoFile(protoInputStream); 94 | cache.put(protoFileName, schema); 95 | } 96 | } 97 | 98 | /** 99 | * 运行时解析proto文件,构造对应的DynamicSchema,用于后续构建DynamicMessage
100 | * 101 | * @param protoInputStream proto协议输入流 102 | */ 103 | private static DynamicSchema parseProtoFile(InputStream protoInputStream) throws Exception { 104 | Injector injector = Guice.createInjector(new ParserModule()); 105 | Importer importer = injector.getInstance(Importer.class); 106 | 107 | ProtoContext context = importer.importFile( 108 | new InputStreamReader(protoInputStream), null); 109 | 110 | DynamicSchema.Builder schemaBuilder = DynamicSchema.newBuilder(); 111 | 112 | context.getProto().getMessages().forEach(e -> { 113 | MessageDefinition msgDef = createMessageDefinition(e); 114 | schemaBuilder.addMessageDefinition(msgDef); 115 | }); 116 | 117 | context.getProto().getEnums().forEach(e -> { 118 | EnumDefinition enumDef = createEnumDefinition(e); 119 | schemaBuilder.addEnumDefinition(enumDef); 120 | }); 121 | protoInputStream.close(); 122 | return schemaBuilder.build(); 123 | } 124 | 125 | 126 | /** 127 | * 按照深度优先顺序,构造含有嵌套的MessageDefinition 128 | */ 129 | private static MessageDefinition createMessageDefinition(Message message) { 130 | Builder builder = MessageDefinition.newBuilder(message.getName()); 131 | for (Field f : message.getFields()) { 132 | if (!f.getType().isScalar() && !f.getType().isMessage()) { 133 | throw new UnsupportedOperationException("unsupported field type in proto."); 134 | } 135 | String label = f.isRepeated() ? "repeated" : "optional"; 136 | builder.addField(label, f.getType().getName(), f.getName(), f.getIndex()); 137 | } 138 | 139 | for (Message nestedMessage : message.getMessages()) { 140 | MessageDefinition nestedMsgDef = createMessageDefinition(nestedMessage); 141 | builder.addMessageDefinition(nestedMsgDef); 142 | } 143 | 144 | for (Enum e : message.getEnums()) { 145 | EnumDefinition enumDef = createEnumDefinition(e); 146 | builder.addEnumDefinition(enumDef); 147 | } 148 | 149 | return builder.build(); 150 | } 151 | 152 | private static EnumDefinition createEnumDefinition(Enum e) { 153 | EnumDefinition.Builder builder = EnumDefinition.newBuilder(e.getName()); 154 | e.getConstants().forEach(c -> { 155 | builder.addValue(c.getName(), c.getValue()); 156 | }); 157 | return builder.build(); 158 | } 159 | 160 | /** 161 | * 将输入的字段根据pb的字段目标类型进行适配: 162 | *
163 |      *  1. 标量值的自动转换
164 |      *  2. 枚举类型的提取
165 |      * 
166 | * 167 | * @param fieldValue 传入的字段值 168 | * @param fd pb字段引用 169 | * @return 符合pb类型的java类型字段值 170 | */ 171 | private static Object getPBValue(Object fieldValue, FieldDescriptor fd, String protoName) { 172 | if (fieldValue == null) { 173 | return null; 174 | } 175 | FieldDescriptor.JavaType javaType = fd.getJavaType(); 176 | switch (javaType) { 177 | case INT: 178 | if (fieldValue instanceof Integer) { 179 | return fieldValue; 180 | } else { 181 | return Integer.parseInt(String.valueOf(fieldValue)); 182 | } 183 | case LONG: 184 | if (fieldValue instanceof Long) { 185 | return fieldValue; 186 | } else { 187 | return Long.parseLong(String.valueOf(fieldValue)); 188 | } 189 | case FLOAT: 190 | if (fieldValue instanceof Float) { 191 | return fieldValue; 192 | } else { 193 | return Float.parseFloat(String.valueOf(fieldValue)); 194 | } 195 | case DOUBLE: 196 | if (fieldValue instanceof Double) { 197 | return fieldValue; 198 | } else { 199 | return Double.parseDouble(String.valueOf(fieldValue)); 200 | } 201 | case BOOLEAN: 202 | if (fieldValue instanceof Boolean) { 203 | return fieldValue; 204 | } else { 205 | return Boolean.parseBoolean(String.valueOf(fieldValue)); 206 | } 207 | case STRING: 208 | if (fieldValue instanceof String) { 209 | return fieldValue; 210 | } else { 211 | return String.valueOf(fieldValue); 212 | } 213 | case ENUM: 214 | return fd.getEnumType().findValueByName(String.valueOf(fieldValue)); 215 | case MESSAGE: 216 | Map fieldValues = (Map) fieldValue; 217 | return buildMessage(protoName, fd.getMessageType().getFullName(), fieldValues); 218 | default: 219 | // BYTE_STRING 220 | throw new UnsupportedOperationException(javaType.name() + " for " + fd.getName() + " not support yet!"); 221 | } 222 | } 223 | 224 | /** 225 | * 动态构建proto message的接口 226 | * 227 | * @param messageName 生成的proto文件中的message名称 228 | * @param fieldValues 要填充的数据,字段名->字段值的映射
229 | * 字段名与proto协议一致,字段值的类型说明如下: 230 | *
    231 | *
  • 标量类型与java类型对应,如int32对应Integer,支持自适应解析转换,如String转int32
  • 232 | *
  • 枚举类型对应枚举值的字符串
  • 233 | *
  • repeated类型对应java.util.ArrayList
  • 234 | *
  • 嵌套的message字段为{@literal Map}
  • 235 | *
236 | * @return 生成的DynamicMessage 237 | */ 238 | public static DynamicMessage buildMessage(String protoName, String messageName, 239 | Map fieldValues) { 240 | DynamicMessage.Builder msgBuilder = Objects.requireNonNull(ProtoHolder.cache.get(protoName), 241 | "use ProtoHolder#registerOrUpdate register your proto first!") 242 | .newMessageBuilder(messageName); 243 | Descriptor msgDesc = msgBuilder.getDescriptorForType(); 244 | 245 | List fdList = msgDesc.getFields(); 246 | 247 | fdList.forEach(fd -> { 248 | String fieldName = fd.getName(); 249 | Object fieldValue = fieldValues.get(fieldName); 250 | if (fd.isRepeated()) { 251 | if (fieldValue != null) { 252 | List values = (List) fieldValue; 253 | for (Object ele : values) { 254 | Object pbValue = getPBValue(ele, fd, protoName); 255 | if (null != pbValue) { 256 | msgBuilder.addRepeatedField(fd, pbValue); 257 | } 258 | } 259 | } 260 | } else { 261 | Object pbValue = getPBValue(fieldValue, fd, protoName); 262 | if (null != pbValue) { 263 | msgBuilder.setField(fd, pbValue); 264 | } 265 | } 266 | }); 267 | return msgBuilder.build(); 268 | } 269 | 270 | public static DynamicMessage parseMessage(String protoName, String messageName, byte[] data) throws Exception { 271 | DynamicMessage.Builder msgBuilder = Objects.requireNonNull(ProtoHolder.cache.get(protoName), 272 | "use ProtoHolder#registerOrUpdate register your proto first!") 273 | .newMessageBuilder(messageName); 274 | Descriptor msgDesc = msgBuilder.getDescriptorForType(); 275 | return DynamicMessage.parseFrom(msgDesc, data); 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /src/test/java/com/fengfshao/dynamicproto/DynamicProtoBuilderTest.java: -------------------------------------------------------------------------------- 1 | package com.fengfshao.dynamicproto; 2 | 3 | import com.fengfshao.dynamicproto.pb3.MultiplePerson; 4 | import com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage; 5 | import com.fengfshao.dynamicproto.pb3.NestedPerson.NestedPersonMessage; 6 | import com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage; 7 | import com.fengfshao.dynamicproto.pb3.SimplePersonV2; 8 | import com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2; 9 | import com.google.protobuf.DynamicMessage; 10 | import com.google.protobuf.Message; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | 14 | import java.util.Arrays; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | /** 20 | * 动态编译生成proto message测试 21 | * 22 | * @author fengfshao 23 | */ 24 | @SuppressWarnings("unchecked") 25 | public class DynamicProtoBuilderTest { 26 | 27 | /** 28 | * 测试简单无嵌套message的生成 29 | */ 30 | @Test 31 | public void buildSimpleMessage() throws Exception { 32 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 33 | Thread.currentThread().getContextClassLoader() 34 | .getResource("simple_person.proto").openStream(), "simple_person.proto"); 35 | 36 | Map fieldValues = new HashMap<>(); 37 | fieldValues.put("id", 1); 38 | fieldValues.put("name", "jihite"); 39 | fieldValues.put("email", "jihite@jihite.com"); 40 | fieldValues.put("address", Arrays.asList("address1", "address2", "address3")); 41 | 42 | Message dynamicMessage = DynamicProtoBuilder 43 | .buildMessage("simple_person.proto", "SimplePersonMessage", fieldValues); 44 | 45 | SimplePersonMessage parsed = SimplePersonMessage.parseFrom(dynamicMessage.toByteArray()); 46 | Assert.assertEquals(1, parsed.getId()); 47 | Assert.assertEquals("jihite", parsed.getName()); 48 | Assert.assertEquals("jihite@jihite.com", parsed.getEmail()); 49 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 50 | } 51 | 52 | /** 53 | * 测试含有枚举类型的Message 54 | */ 55 | @Test 56 | public void buildMessageWithEnum() throws Exception { 57 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 58 | Thread.currentThread().getContextClassLoader() 59 | .getResource("simple_personv2.proto").openStream(), "simple_personv2.proto"); 60 | 61 | Map fieldValues = new HashMap<>(); 62 | fieldValues.put("id", 1); 63 | fieldValues.put("name", "jihite"); 64 | fieldValues.put("email", "jihite@jihite.com"); 65 | fieldValues.put("gender", "MALE"); 66 | fieldValues.put("address", Arrays.asList("address1", "address2", "address3")); 67 | 68 | Message dynamicMessage = DynamicProtoBuilder 69 | .buildMessage("simple_personv2.proto", "SimplePersonMessageV2", fieldValues); 70 | 71 | SimplePersonMessageV2 parsed = SimplePersonMessageV2.parseFrom(dynamicMessage.toByteArray()); 72 | Assert.assertEquals(1, parsed.getId()); 73 | Assert.assertEquals("jihite", parsed.getName()); 74 | Assert.assertEquals("jihite@jihite.com", parsed.getEmail()); 75 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 76 | Assert.assertEquals(SimplePersonV2.Gender.MALE, parsed.getGender()); 77 | } 78 | 79 | /** 80 | * 测试含有嵌套类型的Message 81 | */ 82 | @Test 83 | public void buildNestedMessage() throws Exception { 84 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 85 | Thread.currentThread().getContextClassLoader() 86 | .getResource("nested_person.proto").openStream(), "nested_person.proto"); 87 | 88 | Map fieldValues = new HashMap<>(); 89 | fieldValues.put("id", 1); 90 | fieldValues.put("name", "jihite"); 91 | fieldValues.put("email", "jihite@jihite.com"); 92 | fieldValues.put("gender", "FEMALE"); 93 | fieldValues.put("address", Arrays.asList("address1", "address2", "address3")); 94 | 95 | Map pet1 = new HashMap<>(); 96 | pet1.put("name", "jone"); 97 | pet1.put("age", "3"); 98 | 99 | Map pet2 = new HashMap<>(); 100 | pet2.put("name", "Q"); 101 | pet2.put("age", "5"); 102 | 103 | //fieldValues.put("pets", Arrays.asList(pet1, pet2)); 104 | 105 | Message dynamicMessage = DynamicProtoBuilder 106 | .buildMessage("nested_person.proto", "NestedPersonMessage", fieldValues); 107 | 108 | System.out.println(dynamicMessage); 109 | NestedPersonMessage parsed = NestedPersonMessage.parseFrom(dynamicMessage.toByteArray()); 110 | Assert.assertEquals(1, parsed.getId()); 111 | Assert.assertEquals("jihite", parsed.getName()); 112 | Assert.assertEquals("jihite@jihite.com", parsed.getEmail()); 113 | Assert.assertEquals(NestedPersonMessage.Gender.FEMALE, parsed.getGender()); 114 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 115 | Assert.assertEquals(NestedPersonMessage.Dog.newBuilder() 116 | .setName("jone").setAge(3).build() 117 | , parsed.getPets(0)); 118 | Assert.assertEquals(NestedPersonMessage.Dog.newBuilder() 119 | .setName("Q").setAge(5).build() 120 | , parsed.getPets(1)); 121 | 122 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 123 | 124 | } 125 | 126 | /** 127 | * 测试多Message定义 128 | */ 129 | @Test 130 | public void buildMultipleMessage() throws Exception { 131 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 132 | Thread.currentThread().getContextClassLoader() 133 | .getResource("multiple_person.proto").openStream(), "multiple_person.proto"); 134 | 135 | Map fieldValues = new HashMap<>(); 136 | fieldValues.put("id", 1); 137 | fieldValues.put("name", "jihite"); 138 | fieldValues.put("email", "jihite@jihite.com"); 139 | fieldValues.put("gender", "FEMALE"); 140 | fieldValues.put("address", Arrays.asList("address1", "address2", "address3")); 141 | 142 | Map pet1 = new HashMap<>(); 143 | pet1.put("name", "jone"); 144 | pet1.put("age", "3"); 145 | 146 | Map pet2 = new HashMap<>(); 147 | pet2.put("name", "Q"); 148 | pet2.put("age", "5"); 149 | 150 | fieldValues.put("pets", Arrays.asList(pet1, pet2)); 151 | 152 | Message dynamicMessage = DynamicProtoBuilder 153 | .buildMessage("multiple_person.proto", "MultiplePersonMessage", fieldValues); 154 | 155 | MultiplePersonMessage parsed = MultiplePersonMessage.parseFrom(dynamicMessage.toByteArray()); 156 | Assert.assertEquals(1, parsed.getId()); 157 | Assert.assertEquals("jihite", parsed.getName()); 158 | Assert.assertEquals("jihite@jihite.com", parsed.getEmail()); 159 | Assert.assertEquals(MultiplePerson.Gender.FEMALE, parsed.getGender()); 160 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 161 | Assert.assertEquals(MultiplePerson.Dog.newBuilder() 162 | .setName("jone").setAge(3).build() 163 | , parsed.getPets(0)); 164 | Assert.assertEquals(MultiplePerson.Dog.newBuilder() 165 | .setName("Q").setAge(5).build() 166 | , parsed.getPets(1)); 167 | 168 | Assert.assertEquals(Arrays.asList("address1", "address2", "address3"), parsed.getAddressList()); 169 | } 170 | 171 | @Test 172 | public void parseMessage() throws Exception { 173 | DynamicProtoBuilder.ProtoHolder.registerOrUpdate( 174 | Thread.currentThread().getContextClassLoader() 175 | .getResource("nested_person.proto").openStream(), "nested_person.proto"); 176 | 177 | MultiplePersonMessage.Builder builder = MultiplePersonMessage.newBuilder(); 178 | builder.setName("jihite") 179 | .setEmail("jihite@jihite.com") 180 | .setGender(MultiplePerson.Gender.FEMALE); 181 | 182 | builder.addPets(MultiplePerson.Dog.newBuilder().setName("Q").build()); 183 | byte[] data = builder.build().toByteArray(); 184 | 185 | DynamicMessage message = DynamicProtoBuilder.parseMessage("nested_person.proto", 186 | "NestedPersonMessage", data); 187 | String name = (String) message.getAllFields() 188 | .get(message.getDescriptorForType().findFieldByName("name")); 189 | Assert.assertEquals("jihite", name); 190 | String email = (String) message.getAllFields() 191 | .get(message.getDescriptorForType().findFieldByName("email")); 192 | Assert.assertEquals("jihite@jihite.com", email); 193 | List pets = (List) message.getField( 194 | message.getDescriptorForType().findFieldByName("pets")); 195 | Assert.assertEquals("Q", 196 | pets.get(0).getField(pets.get(0).getDescriptorForType().findFieldByName("name"))); 197 | } 198 | } -------------------------------------------------------------------------------- /src/test/java/com/fengfshao/dynamicproto/pb3/MultiplePerson.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: multiple_person.proto 3 | 4 | package com.fengfshao.dynamicproto.pb3; 5 | 6 | public final class MultiplePerson { 7 | private MultiplePerson() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | /** 18 | * Protobuf enum {@code Gender} 19 | */ 20 | public enum Gender 21 | implements com.google.protobuf.ProtocolMessageEnum { 22 | /** 23 | * MALE = 0; 24 | */ 25 | MALE(0), 26 | /** 27 | * FEMALE = 1; 28 | */ 29 | FEMALE(1), 30 | UNRECOGNIZED(-1), 31 | ; 32 | 33 | /** 34 | * MALE = 0; 35 | */ 36 | public static final int MALE_VALUE = 0; 37 | /** 38 | * FEMALE = 1; 39 | */ 40 | public static final int FEMALE_VALUE = 1; 41 | 42 | 43 | public final int getNumber() { 44 | if (this == UNRECOGNIZED) { 45 | throw new java.lang.IllegalArgumentException( 46 | "Can't get the number of an unknown enum value."); 47 | } 48 | return value; 49 | } 50 | 51 | /** 52 | * @param value The numeric wire value of the corresponding enum entry. 53 | * @return The enum associated with the given numeric wire value. 54 | * @deprecated Use {@link #forNumber(int)} instead. 55 | */ 56 | @java.lang.Deprecated 57 | public static Gender valueOf(int value) { 58 | return forNumber(value); 59 | } 60 | 61 | /** 62 | * @param value The numeric wire value of the corresponding enum entry. 63 | * @return The enum associated with the given numeric wire value. 64 | */ 65 | public static Gender forNumber(int value) { 66 | switch (value) { 67 | case 0: return MALE; 68 | case 1: return FEMALE; 69 | default: return null; 70 | } 71 | } 72 | 73 | public static com.google.protobuf.Internal.EnumLiteMap 74 | internalGetValueMap() { 75 | return internalValueMap; 76 | } 77 | private static final com.google.protobuf.Internal.EnumLiteMap< 78 | Gender> internalValueMap = 79 | new com.google.protobuf.Internal.EnumLiteMap() { 80 | public Gender findValueByNumber(int number) { 81 | return Gender.forNumber(number); 82 | } 83 | }; 84 | 85 | public final com.google.protobuf.Descriptors.EnumValueDescriptor 86 | getValueDescriptor() { 87 | if (this == UNRECOGNIZED) { 88 | throw new java.lang.IllegalStateException( 89 | "Can't get the descriptor of an unrecognized enum value."); 90 | } 91 | return getDescriptor().getValues().get(ordinal()); 92 | } 93 | public final com.google.protobuf.Descriptors.EnumDescriptor 94 | getDescriptorForType() { 95 | return getDescriptor(); 96 | } 97 | public static final com.google.protobuf.Descriptors.EnumDescriptor 98 | getDescriptor() { 99 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.getDescriptor().getEnumTypes().get(0); 100 | } 101 | 102 | private static final Gender[] VALUES = values(); 103 | 104 | public static Gender valueOf( 105 | com.google.protobuf.Descriptors.EnumValueDescriptor desc) { 106 | if (desc.getType() != getDescriptor()) { 107 | throw new java.lang.IllegalArgumentException( 108 | "EnumValueDescriptor is not for this type."); 109 | } 110 | if (desc.getIndex() == -1) { 111 | return UNRECOGNIZED; 112 | } 113 | return VALUES[desc.getIndex()]; 114 | } 115 | 116 | private final int value; 117 | 118 | private Gender(int value) { 119 | this.value = value; 120 | } 121 | 122 | // @@protoc_insertion_point(enum_scope:Gender) 123 | } 124 | 125 | public interface MultiplePersonMessageOrBuilder extends 126 | // @@protoc_insertion_point(interface_extends:MultiplePersonMessage) 127 | com.google.protobuf.MessageOrBuilder { 128 | 129 | /** 130 | * int32 id = 1; 131 | * @return The id. 132 | */ 133 | int getId(); 134 | 135 | /** 136 | * string name = 2; 137 | * @return The name. 138 | */ 139 | java.lang.String getName(); 140 | /** 141 | * string name = 2; 142 | * @return The bytes for name. 143 | */ 144 | com.google.protobuf.ByteString 145 | getNameBytes(); 146 | 147 | /** 148 | * .Gender gender = 3; 149 | * @return The enum numeric value on the wire for gender. 150 | */ 151 | int getGenderValue(); 152 | /** 153 | * .Gender gender = 3; 154 | * @return The gender. 155 | */ 156 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender getGender(); 157 | 158 | /** 159 | * string email = 4; 160 | * @return The email. 161 | */ 162 | java.lang.String getEmail(); 163 | /** 164 | * string email = 4; 165 | * @return The bytes for email. 166 | */ 167 | com.google.protobuf.ByteString 168 | getEmailBytes(); 169 | 170 | /** 171 | * repeated string address = 5; 172 | * @return A list containing the address. 173 | */ 174 | java.util.List 175 | getAddressList(); 176 | /** 177 | * repeated string address = 5; 178 | * @return The count of address. 179 | */ 180 | int getAddressCount(); 181 | /** 182 | * repeated string address = 5; 183 | * @param index The index of the element to return. 184 | * @return The address at the given index. 185 | */ 186 | java.lang.String getAddress(int index); 187 | /** 188 | * repeated string address = 5; 189 | * @param index The index of the value to return. 190 | * @return The bytes of the address at the given index. 191 | */ 192 | com.google.protobuf.ByteString 193 | getAddressBytes(int index); 194 | 195 | /** 196 | * repeated .Dog pets = 6; 197 | */ 198 | java.util.List 199 | getPetsList(); 200 | /** 201 | * repeated .Dog pets = 6; 202 | */ 203 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getPets(int index); 204 | /** 205 | * repeated .Dog pets = 6; 206 | */ 207 | int getPetsCount(); 208 | /** 209 | * repeated .Dog pets = 6; 210 | */ 211 | java.util.List 212 | getPetsOrBuilderList(); 213 | /** 214 | * repeated .Dog pets = 6; 215 | */ 216 | com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder getPetsOrBuilder( 217 | int index); 218 | } 219 | /** 220 | * Protobuf type {@code MultiplePersonMessage} 221 | */ 222 | public static final class MultiplePersonMessage extends 223 | com.google.protobuf.GeneratedMessageV3 implements 224 | // @@protoc_insertion_point(message_implements:MultiplePersonMessage) 225 | MultiplePersonMessageOrBuilder { 226 | private static final long serialVersionUID = 0L; 227 | // Use MultiplePersonMessage.newBuilder() to construct. 228 | private MultiplePersonMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { 229 | super(builder); 230 | } 231 | private MultiplePersonMessage() { 232 | name_ = ""; 233 | gender_ = 0; 234 | email_ = ""; 235 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 236 | pets_ = java.util.Collections.emptyList(); 237 | } 238 | 239 | @java.lang.Override 240 | @SuppressWarnings({"unused"}) 241 | protected java.lang.Object newInstance( 242 | UnusedPrivateParameter unused) { 243 | return new MultiplePersonMessage(); 244 | } 245 | 246 | @java.lang.Override 247 | public final com.google.protobuf.UnknownFieldSet 248 | getUnknownFields() { 249 | return this.unknownFields; 250 | } 251 | private MultiplePersonMessage( 252 | com.google.protobuf.CodedInputStream input, 253 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 254 | throws com.google.protobuf.InvalidProtocolBufferException { 255 | this(); 256 | if (extensionRegistry == null) { 257 | throw new java.lang.NullPointerException(); 258 | } 259 | int mutable_bitField0_ = 0; 260 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 261 | com.google.protobuf.UnknownFieldSet.newBuilder(); 262 | try { 263 | boolean done = false; 264 | while (!done) { 265 | int tag = input.readTag(); 266 | switch (tag) { 267 | case 0: 268 | done = true; 269 | break; 270 | case 8: { 271 | 272 | id_ = input.readInt32(); 273 | break; 274 | } 275 | case 18: { 276 | java.lang.String s = input.readStringRequireUtf8(); 277 | 278 | name_ = s; 279 | break; 280 | } 281 | case 24: { 282 | int rawValue = input.readEnum(); 283 | 284 | gender_ = rawValue; 285 | break; 286 | } 287 | case 34: { 288 | java.lang.String s = input.readStringRequireUtf8(); 289 | 290 | email_ = s; 291 | break; 292 | } 293 | case 42: { 294 | java.lang.String s = input.readStringRequireUtf8(); 295 | if (!((mutable_bitField0_ & 0x00000001) != 0)) { 296 | address_ = new com.google.protobuf.LazyStringArrayList(); 297 | mutable_bitField0_ |= 0x00000001; 298 | } 299 | address_.add(s); 300 | break; 301 | } 302 | case 50: { 303 | if (!((mutable_bitField0_ & 0x00000002) != 0)) { 304 | pets_ = new java.util.ArrayList(); 305 | mutable_bitField0_ |= 0x00000002; 306 | } 307 | pets_.add( 308 | input.readMessage(com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.parser(), extensionRegistry)); 309 | break; 310 | } 311 | default: { 312 | if (!parseUnknownField( 313 | input, unknownFields, extensionRegistry, tag)) { 314 | done = true; 315 | } 316 | break; 317 | } 318 | } 319 | } 320 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 321 | throw e.setUnfinishedMessage(this); 322 | } catch (java.io.IOException e) { 323 | throw new com.google.protobuf.InvalidProtocolBufferException( 324 | e).setUnfinishedMessage(this); 325 | } finally { 326 | if (((mutable_bitField0_ & 0x00000001) != 0)) { 327 | address_ = address_.getUnmodifiableView(); 328 | } 329 | if (((mutable_bitField0_ & 0x00000002) != 0)) { 330 | pets_ = java.util.Collections.unmodifiableList(pets_); 331 | } 332 | this.unknownFields = unknownFields.build(); 333 | makeExtensionsImmutable(); 334 | } 335 | } 336 | public static final com.google.protobuf.Descriptors.Descriptor 337 | getDescriptor() { 338 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_MultiplePersonMessage_descriptor; 339 | } 340 | 341 | @java.lang.Override 342 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 343 | internalGetFieldAccessorTable() { 344 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_MultiplePersonMessage_fieldAccessorTable 345 | .ensureFieldAccessorsInitialized( 346 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.class, com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.Builder.class); 347 | } 348 | 349 | public static final int ID_FIELD_NUMBER = 1; 350 | private int id_; 351 | /** 352 | * int32 id = 1; 353 | * @return The id. 354 | */ 355 | @java.lang.Override 356 | public int getId() { 357 | return id_; 358 | } 359 | 360 | public static final int NAME_FIELD_NUMBER = 2; 361 | private volatile java.lang.Object name_; 362 | /** 363 | * string name = 2; 364 | * @return The name. 365 | */ 366 | @java.lang.Override 367 | public java.lang.String getName() { 368 | java.lang.Object ref = name_; 369 | if (ref instanceof java.lang.String) { 370 | return (java.lang.String) ref; 371 | } else { 372 | com.google.protobuf.ByteString bs = 373 | (com.google.protobuf.ByteString) ref; 374 | java.lang.String s = bs.toStringUtf8(); 375 | name_ = s; 376 | return s; 377 | } 378 | } 379 | /** 380 | * string name = 2; 381 | * @return The bytes for name. 382 | */ 383 | @java.lang.Override 384 | public com.google.protobuf.ByteString 385 | getNameBytes() { 386 | java.lang.Object ref = name_; 387 | if (ref instanceof java.lang.String) { 388 | com.google.protobuf.ByteString b = 389 | com.google.protobuf.ByteString.copyFromUtf8( 390 | (java.lang.String) ref); 391 | name_ = b; 392 | return b; 393 | } else { 394 | return (com.google.protobuf.ByteString) ref; 395 | } 396 | } 397 | 398 | public static final int GENDER_FIELD_NUMBER = 3; 399 | private int gender_; 400 | /** 401 | * .Gender gender = 3; 402 | * @return The enum numeric value on the wire for gender. 403 | */ 404 | @java.lang.Override public int getGenderValue() { 405 | return gender_; 406 | } 407 | /** 408 | * .Gender gender = 3; 409 | * @return The gender. 410 | */ 411 | @java.lang.Override public com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender getGender() { 412 | @SuppressWarnings("deprecation") 413 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender result = com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.valueOf(gender_); 414 | return result == null ? com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.UNRECOGNIZED : result; 415 | } 416 | 417 | public static final int EMAIL_FIELD_NUMBER = 4; 418 | private volatile java.lang.Object email_; 419 | /** 420 | * string email = 4; 421 | * @return The email. 422 | */ 423 | @java.lang.Override 424 | public java.lang.String getEmail() { 425 | java.lang.Object ref = email_; 426 | if (ref instanceof java.lang.String) { 427 | return (java.lang.String) ref; 428 | } else { 429 | com.google.protobuf.ByteString bs = 430 | (com.google.protobuf.ByteString) ref; 431 | java.lang.String s = bs.toStringUtf8(); 432 | email_ = s; 433 | return s; 434 | } 435 | } 436 | /** 437 | * string email = 4; 438 | * @return The bytes for email. 439 | */ 440 | @java.lang.Override 441 | public com.google.protobuf.ByteString 442 | getEmailBytes() { 443 | java.lang.Object ref = email_; 444 | if (ref instanceof java.lang.String) { 445 | com.google.protobuf.ByteString b = 446 | com.google.protobuf.ByteString.copyFromUtf8( 447 | (java.lang.String) ref); 448 | email_ = b; 449 | return b; 450 | } else { 451 | return (com.google.protobuf.ByteString) ref; 452 | } 453 | } 454 | 455 | public static final int ADDRESS_FIELD_NUMBER = 5; 456 | private com.google.protobuf.LazyStringList address_; 457 | /** 458 | * repeated string address = 5; 459 | * @return A list containing the address. 460 | */ 461 | public com.google.protobuf.ProtocolStringList 462 | getAddressList() { 463 | return address_; 464 | } 465 | /** 466 | * repeated string address = 5; 467 | * @return The count of address. 468 | */ 469 | public int getAddressCount() { 470 | return address_.size(); 471 | } 472 | /** 473 | * repeated string address = 5; 474 | * @param index The index of the element to return. 475 | * @return The address at the given index. 476 | */ 477 | public java.lang.String getAddress(int index) { 478 | return address_.get(index); 479 | } 480 | /** 481 | * repeated string address = 5; 482 | * @param index The index of the value to return. 483 | * @return The bytes of the address at the given index. 484 | */ 485 | public com.google.protobuf.ByteString 486 | getAddressBytes(int index) { 487 | return address_.getByteString(index); 488 | } 489 | 490 | public static final int PETS_FIELD_NUMBER = 6; 491 | private java.util.List pets_; 492 | /** 493 | * repeated .Dog pets = 6; 494 | */ 495 | @java.lang.Override 496 | public java.util.List getPetsList() { 497 | return pets_; 498 | } 499 | /** 500 | * repeated .Dog pets = 6; 501 | */ 502 | @java.lang.Override 503 | public java.util.List 504 | getPetsOrBuilderList() { 505 | return pets_; 506 | } 507 | /** 508 | * repeated .Dog pets = 6; 509 | */ 510 | @java.lang.Override 511 | public int getPetsCount() { 512 | return pets_.size(); 513 | } 514 | /** 515 | * repeated .Dog pets = 6; 516 | */ 517 | @java.lang.Override 518 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getPets(int index) { 519 | return pets_.get(index); 520 | } 521 | /** 522 | * repeated .Dog pets = 6; 523 | */ 524 | @java.lang.Override 525 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder getPetsOrBuilder( 526 | int index) { 527 | return pets_.get(index); 528 | } 529 | 530 | private byte memoizedIsInitialized = -1; 531 | @java.lang.Override 532 | public final boolean isInitialized() { 533 | byte isInitialized = memoizedIsInitialized; 534 | if (isInitialized == 1) return true; 535 | if (isInitialized == 0) return false; 536 | 537 | memoizedIsInitialized = 1; 538 | return true; 539 | } 540 | 541 | @java.lang.Override 542 | public void writeTo(com.google.protobuf.CodedOutputStream output) 543 | throws java.io.IOException { 544 | if (id_ != 0) { 545 | output.writeInt32(1, id_); 546 | } 547 | if (!getNameBytes().isEmpty()) { 548 | com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); 549 | } 550 | if (gender_ != com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.MALE.getNumber()) { 551 | output.writeEnum(3, gender_); 552 | } 553 | if (!getEmailBytes().isEmpty()) { 554 | com.google.protobuf.GeneratedMessageV3.writeString(output, 4, email_); 555 | } 556 | for (int i = 0; i < address_.size(); i++) { 557 | com.google.protobuf.GeneratedMessageV3.writeString(output, 5, address_.getRaw(i)); 558 | } 559 | for (int i = 0; i < pets_.size(); i++) { 560 | output.writeMessage(6, pets_.get(i)); 561 | } 562 | unknownFields.writeTo(output); 563 | } 564 | 565 | @java.lang.Override 566 | public int getSerializedSize() { 567 | int size = memoizedSize; 568 | if (size != -1) return size; 569 | 570 | size = 0; 571 | if (id_ != 0) { 572 | size += com.google.protobuf.CodedOutputStream 573 | .computeInt32Size(1, id_); 574 | } 575 | if (!getNameBytes().isEmpty()) { 576 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); 577 | } 578 | if (gender_ != com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.MALE.getNumber()) { 579 | size += com.google.protobuf.CodedOutputStream 580 | .computeEnumSize(3, gender_); 581 | } 582 | if (!getEmailBytes().isEmpty()) { 583 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, email_); 584 | } 585 | { 586 | int dataSize = 0; 587 | for (int i = 0; i < address_.size(); i++) { 588 | dataSize += computeStringSizeNoTag(address_.getRaw(i)); 589 | } 590 | size += dataSize; 591 | size += 1 * getAddressList().size(); 592 | } 593 | for (int i = 0; i < pets_.size(); i++) { 594 | size += com.google.protobuf.CodedOutputStream 595 | .computeMessageSize(6, pets_.get(i)); 596 | } 597 | size += unknownFields.getSerializedSize(); 598 | memoizedSize = size; 599 | return size; 600 | } 601 | 602 | @java.lang.Override 603 | public boolean equals(final java.lang.Object obj) { 604 | if (obj == this) { 605 | return true; 606 | } 607 | if (!(obj instanceof com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage)) { 608 | return super.equals(obj); 609 | } 610 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage other = (com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage) obj; 611 | 612 | if (getId() 613 | != other.getId()) return false; 614 | if (!getName() 615 | .equals(other.getName())) return false; 616 | if (gender_ != other.gender_) return false; 617 | if (!getEmail() 618 | .equals(other.getEmail())) return false; 619 | if (!getAddressList() 620 | .equals(other.getAddressList())) return false; 621 | if (!getPetsList() 622 | .equals(other.getPetsList())) return false; 623 | if (!unknownFields.equals(other.unknownFields)) return false; 624 | return true; 625 | } 626 | 627 | @java.lang.Override 628 | public int hashCode() { 629 | if (memoizedHashCode != 0) { 630 | return memoizedHashCode; 631 | } 632 | int hash = 41; 633 | hash = (19 * hash) + getDescriptor().hashCode(); 634 | hash = (37 * hash) + ID_FIELD_NUMBER; 635 | hash = (53 * hash) + getId(); 636 | hash = (37 * hash) + NAME_FIELD_NUMBER; 637 | hash = (53 * hash) + getName().hashCode(); 638 | hash = (37 * hash) + GENDER_FIELD_NUMBER; 639 | hash = (53 * hash) + gender_; 640 | hash = (37 * hash) + EMAIL_FIELD_NUMBER; 641 | hash = (53 * hash) + getEmail().hashCode(); 642 | if (getAddressCount() > 0) { 643 | hash = (37 * hash) + ADDRESS_FIELD_NUMBER; 644 | hash = (53 * hash) + getAddressList().hashCode(); 645 | } 646 | if (getPetsCount() > 0) { 647 | hash = (37 * hash) + PETS_FIELD_NUMBER; 648 | hash = (53 * hash) + getPetsList().hashCode(); 649 | } 650 | hash = (29 * hash) + unknownFields.hashCode(); 651 | memoizedHashCode = hash; 652 | return hash; 653 | } 654 | 655 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 656 | java.nio.ByteBuffer data) 657 | throws com.google.protobuf.InvalidProtocolBufferException { 658 | return PARSER.parseFrom(data); 659 | } 660 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 661 | java.nio.ByteBuffer data, 662 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 663 | throws com.google.protobuf.InvalidProtocolBufferException { 664 | return PARSER.parseFrom(data, extensionRegistry); 665 | } 666 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 667 | com.google.protobuf.ByteString data) 668 | throws com.google.protobuf.InvalidProtocolBufferException { 669 | return PARSER.parseFrom(data); 670 | } 671 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 672 | com.google.protobuf.ByteString data, 673 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 674 | throws com.google.protobuf.InvalidProtocolBufferException { 675 | return PARSER.parseFrom(data, extensionRegistry); 676 | } 677 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom(byte[] data) 678 | throws com.google.protobuf.InvalidProtocolBufferException { 679 | return PARSER.parseFrom(data); 680 | } 681 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 682 | byte[] data, 683 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 684 | throws com.google.protobuf.InvalidProtocolBufferException { 685 | return PARSER.parseFrom(data, extensionRegistry); 686 | } 687 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom(java.io.InputStream input) 688 | throws java.io.IOException { 689 | return com.google.protobuf.GeneratedMessageV3 690 | .parseWithIOException(PARSER, input); 691 | } 692 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 693 | java.io.InputStream input, 694 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 695 | throws java.io.IOException { 696 | return com.google.protobuf.GeneratedMessageV3 697 | .parseWithIOException(PARSER, input, extensionRegistry); 698 | } 699 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseDelimitedFrom(java.io.InputStream input) 700 | throws java.io.IOException { 701 | return com.google.protobuf.GeneratedMessageV3 702 | .parseDelimitedWithIOException(PARSER, input); 703 | } 704 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseDelimitedFrom( 705 | java.io.InputStream input, 706 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 707 | throws java.io.IOException { 708 | return com.google.protobuf.GeneratedMessageV3 709 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 710 | } 711 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 712 | com.google.protobuf.CodedInputStream input) 713 | throws java.io.IOException { 714 | return com.google.protobuf.GeneratedMessageV3 715 | .parseWithIOException(PARSER, input); 716 | } 717 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parseFrom( 718 | com.google.protobuf.CodedInputStream input, 719 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 720 | throws java.io.IOException { 721 | return com.google.protobuf.GeneratedMessageV3 722 | .parseWithIOException(PARSER, input, extensionRegistry); 723 | } 724 | 725 | @java.lang.Override 726 | public Builder newBuilderForType() { return newBuilder(); } 727 | public static Builder newBuilder() { 728 | return DEFAULT_INSTANCE.toBuilder(); 729 | } 730 | public static Builder newBuilder(com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage prototype) { 731 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 732 | } 733 | @java.lang.Override 734 | public Builder toBuilder() { 735 | return this == DEFAULT_INSTANCE 736 | ? new Builder() : new Builder().mergeFrom(this); 737 | } 738 | 739 | @java.lang.Override 740 | protected Builder newBuilderForType( 741 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 742 | Builder builder = new Builder(parent); 743 | return builder; 744 | } 745 | /** 746 | * Protobuf type {@code MultiplePersonMessage} 747 | */ 748 | public static final class Builder extends 749 | com.google.protobuf.GeneratedMessageV3.Builder implements 750 | // @@protoc_insertion_point(builder_implements:MultiplePersonMessage) 751 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessageOrBuilder { 752 | public static final com.google.protobuf.Descriptors.Descriptor 753 | getDescriptor() { 754 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_MultiplePersonMessage_descriptor; 755 | } 756 | 757 | @java.lang.Override 758 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 759 | internalGetFieldAccessorTable() { 760 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_MultiplePersonMessage_fieldAccessorTable 761 | .ensureFieldAccessorsInitialized( 762 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.class, com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.Builder.class); 763 | } 764 | 765 | // Construct using com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.newBuilder() 766 | private Builder() { 767 | maybeForceBuilderInitialization(); 768 | } 769 | 770 | private Builder( 771 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 772 | super(parent); 773 | maybeForceBuilderInitialization(); 774 | } 775 | private void maybeForceBuilderInitialization() { 776 | if (com.google.protobuf.GeneratedMessageV3 777 | .alwaysUseFieldBuilders) { 778 | getPetsFieldBuilder(); 779 | } 780 | } 781 | @java.lang.Override 782 | public Builder clear() { 783 | super.clear(); 784 | id_ = 0; 785 | 786 | name_ = ""; 787 | 788 | gender_ = 0; 789 | 790 | email_ = ""; 791 | 792 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 793 | bitField0_ = (bitField0_ & ~0x00000001); 794 | if (petsBuilder_ == null) { 795 | pets_ = java.util.Collections.emptyList(); 796 | bitField0_ = (bitField0_ & ~0x00000002); 797 | } else { 798 | petsBuilder_.clear(); 799 | } 800 | return this; 801 | } 802 | 803 | @java.lang.Override 804 | public com.google.protobuf.Descriptors.Descriptor 805 | getDescriptorForType() { 806 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_MultiplePersonMessage_descriptor; 807 | } 808 | 809 | @java.lang.Override 810 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage getDefaultInstanceForType() { 811 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.getDefaultInstance(); 812 | } 813 | 814 | @java.lang.Override 815 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage build() { 816 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage result = buildPartial(); 817 | if (!result.isInitialized()) { 818 | throw newUninitializedMessageException(result); 819 | } 820 | return result; 821 | } 822 | 823 | @java.lang.Override 824 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage buildPartial() { 825 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage result = new com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage(this); 826 | int from_bitField0_ = bitField0_; 827 | result.id_ = id_; 828 | result.name_ = name_; 829 | result.gender_ = gender_; 830 | result.email_ = email_; 831 | if (((bitField0_ & 0x00000001) != 0)) { 832 | address_ = address_.getUnmodifiableView(); 833 | bitField0_ = (bitField0_ & ~0x00000001); 834 | } 835 | result.address_ = address_; 836 | if (petsBuilder_ == null) { 837 | if (((bitField0_ & 0x00000002) != 0)) { 838 | pets_ = java.util.Collections.unmodifiableList(pets_); 839 | bitField0_ = (bitField0_ & ~0x00000002); 840 | } 841 | result.pets_ = pets_; 842 | } else { 843 | result.pets_ = petsBuilder_.build(); 844 | } 845 | onBuilt(); 846 | return result; 847 | } 848 | 849 | @java.lang.Override 850 | public Builder clone() { 851 | return super.clone(); 852 | } 853 | @java.lang.Override 854 | public Builder setField( 855 | com.google.protobuf.Descriptors.FieldDescriptor field, 856 | java.lang.Object value) { 857 | return super.setField(field, value); 858 | } 859 | @java.lang.Override 860 | public Builder clearField( 861 | com.google.protobuf.Descriptors.FieldDescriptor field) { 862 | return super.clearField(field); 863 | } 864 | @java.lang.Override 865 | public Builder clearOneof( 866 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 867 | return super.clearOneof(oneof); 868 | } 869 | @java.lang.Override 870 | public Builder setRepeatedField( 871 | com.google.protobuf.Descriptors.FieldDescriptor field, 872 | int index, java.lang.Object value) { 873 | return super.setRepeatedField(field, index, value); 874 | } 875 | @java.lang.Override 876 | public Builder addRepeatedField( 877 | com.google.protobuf.Descriptors.FieldDescriptor field, 878 | java.lang.Object value) { 879 | return super.addRepeatedField(field, value); 880 | } 881 | @java.lang.Override 882 | public Builder mergeFrom(com.google.protobuf.Message other) { 883 | if (other instanceof com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage) { 884 | return mergeFrom((com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage)other); 885 | } else { 886 | super.mergeFrom(other); 887 | return this; 888 | } 889 | } 890 | 891 | public Builder mergeFrom(com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage other) { 892 | if (other == com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage.getDefaultInstance()) return this; 893 | if (other.getId() != 0) { 894 | setId(other.getId()); 895 | } 896 | if (!other.getName().isEmpty()) { 897 | name_ = other.name_; 898 | onChanged(); 899 | } 900 | if (other.gender_ != 0) { 901 | setGenderValue(other.getGenderValue()); 902 | } 903 | if (!other.getEmail().isEmpty()) { 904 | email_ = other.email_; 905 | onChanged(); 906 | } 907 | if (!other.address_.isEmpty()) { 908 | if (address_.isEmpty()) { 909 | address_ = other.address_; 910 | bitField0_ = (bitField0_ & ~0x00000001); 911 | } else { 912 | ensureAddressIsMutable(); 913 | address_.addAll(other.address_); 914 | } 915 | onChanged(); 916 | } 917 | if (petsBuilder_ == null) { 918 | if (!other.pets_.isEmpty()) { 919 | if (pets_.isEmpty()) { 920 | pets_ = other.pets_; 921 | bitField0_ = (bitField0_ & ~0x00000002); 922 | } else { 923 | ensurePetsIsMutable(); 924 | pets_.addAll(other.pets_); 925 | } 926 | onChanged(); 927 | } 928 | } else { 929 | if (!other.pets_.isEmpty()) { 930 | if (petsBuilder_.isEmpty()) { 931 | petsBuilder_.dispose(); 932 | petsBuilder_ = null; 933 | pets_ = other.pets_; 934 | bitField0_ = (bitField0_ & ~0x00000002); 935 | petsBuilder_ = 936 | com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? 937 | getPetsFieldBuilder() : null; 938 | } else { 939 | petsBuilder_.addAllMessages(other.pets_); 940 | } 941 | } 942 | } 943 | this.mergeUnknownFields(other.unknownFields); 944 | onChanged(); 945 | return this; 946 | } 947 | 948 | @java.lang.Override 949 | public final boolean isInitialized() { 950 | return true; 951 | } 952 | 953 | @java.lang.Override 954 | public Builder mergeFrom( 955 | com.google.protobuf.CodedInputStream input, 956 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 957 | throws java.io.IOException { 958 | com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage parsedMessage = null; 959 | try { 960 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 961 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 962 | parsedMessage = (com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage) e.getUnfinishedMessage(); 963 | throw e.unwrapIOException(); 964 | } finally { 965 | if (parsedMessage != null) { 966 | mergeFrom(parsedMessage); 967 | } 968 | } 969 | return this; 970 | } 971 | private int bitField0_; 972 | 973 | private int id_ ; 974 | /** 975 | * int32 id = 1; 976 | * @return The id. 977 | */ 978 | @java.lang.Override 979 | public int getId() { 980 | return id_; 981 | } 982 | /** 983 | * int32 id = 1; 984 | * @param value The id to set. 985 | * @return This builder for chaining. 986 | */ 987 | public Builder setId(int value) { 988 | 989 | id_ = value; 990 | onChanged(); 991 | return this; 992 | } 993 | /** 994 | * int32 id = 1; 995 | * @return This builder for chaining. 996 | */ 997 | public Builder clearId() { 998 | 999 | id_ = 0; 1000 | onChanged(); 1001 | return this; 1002 | } 1003 | 1004 | private java.lang.Object name_ = ""; 1005 | /** 1006 | * string name = 2; 1007 | * @return The name. 1008 | */ 1009 | public java.lang.String getName() { 1010 | java.lang.Object ref = name_; 1011 | if (!(ref instanceof java.lang.String)) { 1012 | com.google.protobuf.ByteString bs = 1013 | (com.google.protobuf.ByteString) ref; 1014 | java.lang.String s = bs.toStringUtf8(); 1015 | name_ = s; 1016 | return s; 1017 | } else { 1018 | return (java.lang.String) ref; 1019 | } 1020 | } 1021 | /** 1022 | * string name = 2; 1023 | * @return The bytes for name. 1024 | */ 1025 | public com.google.protobuf.ByteString 1026 | getNameBytes() { 1027 | java.lang.Object ref = name_; 1028 | if (ref instanceof String) { 1029 | com.google.protobuf.ByteString b = 1030 | com.google.protobuf.ByteString.copyFromUtf8( 1031 | (java.lang.String) ref); 1032 | name_ = b; 1033 | return b; 1034 | } else { 1035 | return (com.google.protobuf.ByteString) ref; 1036 | } 1037 | } 1038 | /** 1039 | * string name = 2; 1040 | * @param value The name to set. 1041 | * @return This builder for chaining. 1042 | */ 1043 | public Builder setName( 1044 | java.lang.String value) { 1045 | if (value == null) { 1046 | throw new NullPointerException(); 1047 | } 1048 | 1049 | name_ = value; 1050 | onChanged(); 1051 | return this; 1052 | } 1053 | /** 1054 | * string name = 2; 1055 | * @return This builder for chaining. 1056 | */ 1057 | public Builder clearName() { 1058 | 1059 | name_ = getDefaultInstance().getName(); 1060 | onChanged(); 1061 | return this; 1062 | } 1063 | /** 1064 | * string name = 2; 1065 | * @param value The bytes for name to set. 1066 | * @return This builder for chaining. 1067 | */ 1068 | public Builder setNameBytes( 1069 | com.google.protobuf.ByteString value) { 1070 | if (value == null) { 1071 | throw new NullPointerException(); 1072 | } 1073 | checkByteStringIsUtf8(value); 1074 | 1075 | name_ = value; 1076 | onChanged(); 1077 | return this; 1078 | } 1079 | 1080 | private int gender_ = 0; 1081 | /** 1082 | * .Gender gender = 3; 1083 | * @return The enum numeric value on the wire for gender. 1084 | */ 1085 | @java.lang.Override public int getGenderValue() { 1086 | return gender_; 1087 | } 1088 | /** 1089 | * .Gender gender = 3; 1090 | * @param value The enum numeric value on the wire for gender to set. 1091 | * @return This builder for chaining. 1092 | */ 1093 | public Builder setGenderValue(int value) { 1094 | 1095 | gender_ = value; 1096 | onChanged(); 1097 | return this; 1098 | } 1099 | /** 1100 | * .Gender gender = 3; 1101 | * @return The gender. 1102 | */ 1103 | @java.lang.Override 1104 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender getGender() { 1105 | @SuppressWarnings("deprecation") 1106 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender result = com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.valueOf(gender_); 1107 | return result == null ? com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender.UNRECOGNIZED : result; 1108 | } 1109 | /** 1110 | * .Gender gender = 3; 1111 | * @param value The gender to set. 1112 | * @return This builder for chaining. 1113 | */ 1114 | public Builder setGender(com.fengfshao.dynamicproto.pb3.MultiplePerson.Gender value) { 1115 | if (value == null) { 1116 | throw new NullPointerException(); 1117 | } 1118 | 1119 | gender_ = value.getNumber(); 1120 | onChanged(); 1121 | return this; 1122 | } 1123 | /** 1124 | * .Gender gender = 3; 1125 | * @return This builder for chaining. 1126 | */ 1127 | public Builder clearGender() { 1128 | 1129 | gender_ = 0; 1130 | onChanged(); 1131 | return this; 1132 | } 1133 | 1134 | private java.lang.Object email_ = ""; 1135 | /** 1136 | * string email = 4; 1137 | * @return The email. 1138 | */ 1139 | public java.lang.String getEmail() { 1140 | java.lang.Object ref = email_; 1141 | if (!(ref instanceof java.lang.String)) { 1142 | com.google.protobuf.ByteString bs = 1143 | (com.google.protobuf.ByteString) ref; 1144 | java.lang.String s = bs.toStringUtf8(); 1145 | email_ = s; 1146 | return s; 1147 | } else { 1148 | return (java.lang.String) ref; 1149 | } 1150 | } 1151 | /** 1152 | * string email = 4; 1153 | * @return The bytes for email. 1154 | */ 1155 | public com.google.protobuf.ByteString 1156 | getEmailBytes() { 1157 | java.lang.Object ref = email_; 1158 | if (ref instanceof String) { 1159 | com.google.protobuf.ByteString b = 1160 | com.google.protobuf.ByteString.copyFromUtf8( 1161 | (java.lang.String) ref); 1162 | email_ = b; 1163 | return b; 1164 | } else { 1165 | return (com.google.protobuf.ByteString) ref; 1166 | } 1167 | } 1168 | /** 1169 | * string email = 4; 1170 | * @param value The email to set. 1171 | * @return This builder for chaining. 1172 | */ 1173 | public Builder setEmail( 1174 | java.lang.String value) { 1175 | if (value == null) { 1176 | throw new NullPointerException(); 1177 | } 1178 | 1179 | email_ = value; 1180 | onChanged(); 1181 | return this; 1182 | } 1183 | /** 1184 | * string email = 4; 1185 | * @return This builder for chaining. 1186 | */ 1187 | public Builder clearEmail() { 1188 | 1189 | email_ = getDefaultInstance().getEmail(); 1190 | onChanged(); 1191 | return this; 1192 | } 1193 | /** 1194 | * string email = 4; 1195 | * @param value The bytes for email to set. 1196 | * @return This builder for chaining. 1197 | */ 1198 | public Builder setEmailBytes( 1199 | com.google.protobuf.ByteString value) { 1200 | if (value == null) { 1201 | throw new NullPointerException(); 1202 | } 1203 | checkByteStringIsUtf8(value); 1204 | 1205 | email_ = value; 1206 | onChanged(); 1207 | return this; 1208 | } 1209 | 1210 | private com.google.protobuf.LazyStringList address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 1211 | private void ensureAddressIsMutable() { 1212 | if (!((bitField0_ & 0x00000001) != 0)) { 1213 | address_ = new com.google.protobuf.LazyStringArrayList(address_); 1214 | bitField0_ |= 0x00000001; 1215 | } 1216 | } 1217 | /** 1218 | * repeated string address = 5; 1219 | * @return A list containing the address. 1220 | */ 1221 | public com.google.protobuf.ProtocolStringList 1222 | getAddressList() { 1223 | return address_.getUnmodifiableView(); 1224 | } 1225 | /** 1226 | * repeated string address = 5; 1227 | * @return The count of address. 1228 | */ 1229 | public int getAddressCount() { 1230 | return address_.size(); 1231 | } 1232 | /** 1233 | * repeated string address = 5; 1234 | * @param index The index of the element to return. 1235 | * @return The address at the given index. 1236 | */ 1237 | public java.lang.String getAddress(int index) { 1238 | return address_.get(index); 1239 | } 1240 | /** 1241 | * repeated string address = 5; 1242 | * @param index The index of the value to return. 1243 | * @return The bytes of the address at the given index. 1244 | */ 1245 | public com.google.protobuf.ByteString 1246 | getAddressBytes(int index) { 1247 | return address_.getByteString(index); 1248 | } 1249 | /** 1250 | * repeated string address = 5; 1251 | * @param index The index to set the value at. 1252 | * @param value The address to set. 1253 | * @return This builder for chaining. 1254 | */ 1255 | public Builder setAddress( 1256 | int index, java.lang.String value) { 1257 | if (value == null) { 1258 | throw new NullPointerException(); 1259 | } 1260 | ensureAddressIsMutable(); 1261 | address_.set(index, value); 1262 | onChanged(); 1263 | return this; 1264 | } 1265 | /** 1266 | * repeated string address = 5; 1267 | * @param value The address to add. 1268 | * @return This builder for chaining. 1269 | */ 1270 | public Builder addAddress( 1271 | java.lang.String value) { 1272 | if (value == null) { 1273 | throw new NullPointerException(); 1274 | } 1275 | ensureAddressIsMutable(); 1276 | address_.add(value); 1277 | onChanged(); 1278 | return this; 1279 | } 1280 | /** 1281 | * repeated string address = 5; 1282 | * @param values The address to add. 1283 | * @return This builder for chaining. 1284 | */ 1285 | public Builder addAllAddress( 1286 | java.lang.Iterable values) { 1287 | ensureAddressIsMutable(); 1288 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 1289 | values, address_); 1290 | onChanged(); 1291 | return this; 1292 | } 1293 | /** 1294 | * repeated string address = 5; 1295 | * @return This builder for chaining. 1296 | */ 1297 | public Builder clearAddress() { 1298 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 1299 | bitField0_ = (bitField0_ & ~0x00000001); 1300 | onChanged(); 1301 | return this; 1302 | } 1303 | /** 1304 | * repeated string address = 5; 1305 | * @param value The bytes of the address to add. 1306 | * @return This builder for chaining. 1307 | */ 1308 | public Builder addAddressBytes( 1309 | com.google.protobuf.ByteString value) { 1310 | if (value == null) { 1311 | throw new NullPointerException(); 1312 | } 1313 | checkByteStringIsUtf8(value); 1314 | ensureAddressIsMutable(); 1315 | address_.add(value); 1316 | onChanged(); 1317 | return this; 1318 | } 1319 | 1320 | private java.util.List pets_ = 1321 | java.util.Collections.emptyList(); 1322 | private void ensurePetsIsMutable() { 1323 | if (!((bitField0_ & 0x00000002) != 0)) { 1324 | pets_ = new java.util.ArrayList(pets_); 1325 | bitField0_ |= 0x00000002; 1326 | } 1327 | } 1328 | 1329 | private com.google.protobuf.RepeatedFieldBuilderV3< 1330 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder, com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder> petsBuilder_; 1331 | 1332 | /** 1333 | * repeated .Dog pets = 6; 1334 | */ 1335 | public java.util.List getPetsList() { 1336 | if (petsBuilder_ == null) { 1337 | return java.util.Collections.unmodifiableList(pets_); 1338 | } else { 1339 | return petsBuilder_.getMessageList(); 1340 | } 1341 | } 1342 | /** 1343 | * repeated .Dog pets = 6; 1344 | */ 1345 | public int getPetsCount() { 1346 | if (petsBuilder_ == null) { 1347 | return pets_.size(); 1348 | } else { 1349 | return petsBuilder_.getCount(); 1350 | } 1351 | } 1352 | /** 1353 | * repeated .Dog pets = 6; 1354 | */ 1355 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getPets(int index) { 1356 | if (petsBuilder_ == null) { 1357 | return pets_.get(index); 1358 | } else { 1359 | return petsBuilder_.getMessage(index); 1360 | } 1361 | } 1362 | /** 1363 | * repeated .Dog pets = 6; 1364 | */ 1365 | public Builder setPets( 1366 | int index, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog value) { 1367 | if (petsBuilder_ == null) { 1368 | if (value == null) { 1369 | throw new NullPointerException(); 1370 | } 1371 | ensurePetsIsMutable(); 1372 | pets_.set(index, value); 1373 | onChanged(); 1374 | } else { 1375 | petsBuilder_.setMessage(index, value); 1376 | } 1377 | return this; 1378 | } 1379 | /** 1380 | * repeated .Dog pets = 6; 1381 | */ 1382 | public Builder setPets( 1383 | int index, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder builderForValue) { 1384 | if (petsBuilder_ == null) { 1385 | ensurePetsIsMutable(); 1386 | pets_.set(index, builderForValue.build()); 1387 | onChanged(); 1388 | } else { 1389 | petsBuilder_.setMessage(index, builderForValue.build()); 1390 | } 1391 | return this; 1392 | } 1393 | /** 1394 | * repeated .Dog pets = 6; 1395 | */ 1396 | public Builder addPets(com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog value) { 1397 | if (petsBuilder_ == null) { 1398 | if (value == null) { 1399 | throw new NullPointerException(); 1400 | } 1401 | ensurePetsIsMutable(); 1402 | pets_.add(value); 1403 | onChanged(); 1404 | } else { 1405 | petsBuilder_.addMessage(value); 1406 | } 1407 | return this; 1408 | } 1409 | /** 1410 | * repeated .Dog pets = 6; 1411 | */ 1412 | public Builder addPets( 1413 | int index, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog value) { 1414 | if (petsBuilder_ == null) { 1415 | if (value == null) { 1416 | throw new NullPointerException(); 1417 | } 1418 | ensurePetsIsMutable(); 1419 | pets_.add(index, value); 1420 | onChanged(); 1421 | } else { 1422 | petsBuilder_.addMessage(index, value); 1423 | } 1424 | return this; 1425 | } 1426 | /** 1427 | * repeated .Dog pets = 6; 1428 | */ 1429 | public Builder addPets( 1430 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder builderForValue) { 1431 | if (petsBuilder_ == null) { 1432 | ensurePetsIsMutable(); 1433 | pets_.add(builderForValue.build()); 1434 | onChanged(); 1435 | } else { 1436 | petsBuilder_.addMessage(builderForValue.build()); 1437 | } 1438 | return this; 1439 | } 1440 | /** 1441 | * repeated .Dog pets = 6; 1442 | */ 1443 | public Builder addPets( 1444 | int index, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder builderForValue) { 1445 | if (petsBuilder_ == null) { 1446 | ensurePetsIsMutable(); 1447 | pets_.add(index, builderForValue.build()); 1448 | onChanged(); 1449 | } else { 1450 | petsBuilder_.addMessage(index, builderForValue.build()); 1451 | } 1452 | return this; 1453 | } 1454 | /** 1455 | * repeated .Dog pets = 6; 1456 | */ 1457 | public Builder addAllPets( 1458 | java.lang.Iterable values) { 1459 | if (petsBuilder_ == null) { 1460 | ensurePetsIsMutable(); 1461 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 1462 | values, pets_); 1463 | onChanged(); 1464 | } else { 1465 | petsBuilder_.addAllMessages(values); 1466 | } 1467 | return this; 1468 | } 1469 | /** 1470 | * repeated .Dog pets = 6; 1471 | */ 1472 | public Builder clearPets() { 1473 | if (petsBuilder_ == null) { 1474 | pets_ = java.util.Collections.emptyList(); 1475 | bitField0_ = (bitField0_ & ~0x00000002); 1476 | onChanged(); 1477 | } else { 1478 | petsBuilder_.clear(); 1479 | } 1480 | return this; 1481 | } 1482 | /** 1483 | * repeated .Dog pets = 6; 1484 | */ 1485 | public Builder removePets(int index) { 1486 | if (petsBuilder_ == null) { 1487 | ensurePetsIsMutable(); 1488 | pets_.remove(index); 1489 | onChanged(); 1490 | } else { 1491 | petsBuilder_.remove(index); 1492 | } 1493 | return this; 1494 | } 1495 | /** 1496 | * repeated .Dog pets = 6; 1497 | */ 1498 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder getPetsBuilder( 1499 | int index) { 1500 | return getPetsFieldBuilder().getBuilder(index); 1501 | } 1502 | /** 1503 | * repeated .Dog pets = 6; 1504 | */ 1505 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder getPetsOrBuilder( 1506 | int index) { 1507 | if (petsBuilder_ == null) { 1508 | return pets_.get(index); } else { 1509 | return petsBuilder_.getMessageOrBuilder(index); 1510 | } 1511 | } 1512 | /** 1513 | * repeated .Dog pets = 6; 1514 | */ 1515 | public java.util.List 1516 | getPetsOrBuilderList() { 1517 | if (petsBuilder_ != null) { 1518 | return petsBuilder_.getMessageOrBuilderList(); 1519 | } else { 1520 | return java.util.Collections.unmodifiableList(pets_); 1521 | } 1522 | } 1523 | /** 1524 | * repeated .Dog pets = 6; 1525 | */ 1526 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder addPetsBuilder() { 1527 | return getPetsFieldBuilder().addBuilder( 1528 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.getDefaultInstance()); 1529 | } 1530 | /** 1531 | * repeated .Dog pets = 6; 1532 | */ 1533 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder addPetsBuilder( 1534 | int index) { 1535 | return getPetsFieldBuilder().addBuilder( 1536 | index, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.getDefaultInstance()); 1537 | } 1538 | /** 1539 | * repeated .Dog pets = 6; 1540 | */ 1541 | public java.util.List 1542 | getPetsBuilderList() { 1543 | return getPetsFieldBuilder().getBuilderList(); 1544 | } 1545 | private com.google.protobuf.RepeatedFieldBuilderV3< 1546 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder, com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder> 1547 | getPetsFieldBuilder() { 1548 | if (petsBuilder_ == null) { 1549 | petsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< 1550 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder, com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder>( 1551 | pets_, 1552 | ((bitField0_ & 0x00000002) != 0), 1553 | getParentForChildren(), 1554 | isClean()); 1555 | pets_ = null; 1556 | } 1557 | return petsBuilder_; 1558 | } 1559 | @java.lang.Override 1560 | public final Builder setUnknownFields( 1561 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1562 | return super.setUnknownFields(unknownFields); 1563 | } 1564 | 1565 | @java.lang.Override 1566 | public final Builder mergeUnknownFields( 1567 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1568 | return super.mergeUnknownFields(unknownFields); 1569 | } 1570 | 1571 | 1572 | // @@protoc_insertion_point(builder_scope:MultiplePersonMessage) 1573 | } 1574 | 1575 | // @@protoc_insertion_point(class_scope:MultiplePersonMessage) 1576 | private static final com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage DEFAULT_INSTANCE; 1577 | static { 1578 | DEFAULT_INSTANCE = new com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage(); 1579 | } 1580 | 1581 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage getDefaultInstance() { 1582 | return DEFAULT_INSTANCE; 1583 | } 1584 | 1585 | private static final com.google.protobuf.Parser 1586 | PARSER = new com.google.protobuf.AbstractParser() { 1587 | @java.lang.Override 1588 | public MultiplePersonMessage parsePartialFrom( 1589 | com.google.protobuf.CodedInputStream input, 1590 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1591 | throws com.google.protobuf.InvalidProtocolBufferException { 1592 | return new MultiplePersonMessage(input, extensionRegistry); 1593 | } 1594 | }; 1595 | 1596 | public static com.google.protobuf.Parser parser() { 1597 | return PARSER; 1598 | } 1599 | 1600 | @java.lang.Override 1601 | public com.google.protobuf.Parser getParserForType() { 1602 | return PARSER; 1603 | } 1604 | 1605 | @java.lang.Override 1606 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.MultiplePersonMessage getDefaultInstanceForType() { 1607 | return DEFAULT_INSTANCE; 1608 | } 1609 | 1610 | } 1611 | 1612 | public interface DogOrBuilder extends 1613 | // @@protoc_insertion_point(interface_extends:Dog) 1614 | com.google.protobuf.MessageOrBuilder { 1615 | 1616 | /** 1617 | * string name = 1; 1618 | * @return The name. 1619 | */ 1620 | java.lang.String getName(); 1621 | /** 1622 | * string name = 1; 1623 | * @return The bytes for name. 1624 | */ 1625 | com.google.protobuf.ByteString 1626 | getNameBytes(); 1627 | 1628 | /** 1629 | * int32 age = 2; 1630 | * @return The age. 1631 | */ 1632 | int getAge(); 1633 | } 1634 | /** 1635 | * Protobuf type {@code Dog} 1636 | */ 1637 | public static final class Dog extends 1638 | com.google.protobuf.GeneratedMessageV3 implements 1639 | // @@protoc_insertion_point(message_implements:Dog) 1640 | DogOrBuilder { 1641 | private static final long serialVersionUID = 0L; 1642 | // Use Dog.newBuilder() to construct. 1643 | private Dog(com.google.protobuf.GeneratedMessageV3.Builder builder) { 1644 | super(builder); 1645 | } 1646 | private Dog() { 1647 | name_ = ""; 1648 | } 1649 | 1650 | @java.lang.Override 1651 | @SuppressWarnings({"unused"}) 1652 | protected java.lang.Object newInstance( 1653 | UnusedPrivateParameter unused) { 1654 | return new Dog(); 1655 | } 1656 | 1657 | @java.lang.Override 1658 | public final com.google.protobuf.UnknownFieldSet 1659 | getUnknownFields() { 1660 | return this.unknownFields; 1661 | } 1662 | private Dog( 1663 | com.google.protobuf.CodedInputStream input, 1664 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1665 | throws com.google.protobuf.InvalidProtocolBufferException { 1666 | this(); 1667 | if (extensionRegistry == null) { 1668 | throw new java.lang.NullPointerException(); 1669 | } 1670 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 1671 | com.google.protobuf.UnknownFieldSet.newBuilder(); 1672 | try { 1673 | boolean done = false; 1674 | while (!done) { 1675 | int tag = input.readTag(); 1676 | switch (tag) { 1677 | case 0: 1678 | done = true; 1679 | break; 1680 | case 10: { 1681 | java.lang.String s = input.readStringRequireUtf8(); 1682 | 1683 | name_ = s; 1684 | break; 1685 | } 1686 | case 16: { 1687 | 1688 | age_ = input.readInt32(); 1689 | break; 1690 | } 1691 | default: { 1692 | if (!parseUnknownField( 1693 | input, unknownFields, extensionRegistry, tag)) { 1694 | done = true; 1695 | } 1696 | break; 1697 | } 1698 | } 1699 | } 1700 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1701 | throw e.setUnfinishedMessage(this); 1702 | } catch (java.io.IOException e) { 1703 | throw new com.google.protobuf.InvalidProtocolBufferException( 1704 | e).setUnfinishedMessage(this); 1705 | } finally { 1706 | this.unknownFields = unknownFields.build(); 1707 | makeExtensionsImmutable(); 1708 | } 1709 | } 1710 | public static final com.google.protobuf.Descriptors.Descriptor 1711 | getDescriptor() { 1712 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_Dog_descriptor; 1713 | } 1714 | 1715 | @java.lang.Override 1716 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1717 | internalGetFieldAccessorTable() { 1718 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_Dog_fieldAccessorTable 1719 | .ensureFieldAccessorsInitialized( 1720 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.class, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder.class); 1721 | } 1722 | 1723 | public static final int NAME_FIELD_NUMBER = 1; 1724 | private volatile java.lang.Object name_; 1725 | /** 1726 | * string name = 1; 1727 | * @return The name. 1728 | */ 1729 | @java.lang.Override 1730 | public java.lang.String getName() { 1731 | java.lang.Object ref = name_; 1732 | if (ref instanceof java.lang.String) { 1733 | return (java.lang.String) ref; 1734 | } else { 1735 | com.google.protobuf.ByteString bs = 1736 | (com.google.protobuf.ByteString) ref; 1737 | java.lang.String s = bs.toStringUtf8(); 1738 | name_ = s; 1739 | return s; 1740 | } 1741 | } 1742 | /** 1743 | * string name = 1; 1744 | * @return The bytes for name. 1745 | */ 1746 | @java.lang.Override 1747 | public com.google.protobuf.ByteString 1748 | getNameBytes() { 1749 | java.lang.Object ref = name_; 1750 | if (ref instanceof java.lang.String) { 1751 | com.google.protobuf.ByteString b = 1752 | com.google.protobuf.ByteString.copyFromUtf8( 1753 | (java.lang.String) ref); 1754 | name_ = b; 1755 | return b; 1756 | } else { 1757 | return (com.google.protobuf.ByteString) ref; 1758 | } 1759 | } 1760 | 1761 | public static final int AGE_FIELD_NUMBER = 2; 1762 | private int age_; 1763 | /** 1764 | * int32 age = 2; 1765 | * @return The age. 1766 | */ 1767 | @java.lang.Override 1768 | public int getAge() { 1769 | return age_; 1770 | } 1771 | 1772 | private byte memoizedIsInitialized = -1; 1773 | @java.lang.Override 1774 | public final boolean isInitialized() { 1775 | byte isInitialized = memoizedIsInitialized; 1776 | if (isInitialized == 1) return true; 1777 | if (isInitialized == 0) return false; 1778 | 1779 | memoizedIsInitialized = 1; 1780 | return true; 1781 | } 1782 | 1783 | @java.lang.Override 1784 | public void writeTo(com.google.protobuf.CodedOutputStream output) 1785 | throws java.io.IOException { 1786 | if (!getNameBytes().isEmpty()) { 1787 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); 1788 | } 1789 | if (age_ != 0) { 1790 | output.writeInt32(2, age_); 1791 | } 1792 | unknownFields.writeTo(output); 1793 | } 1794 | 1795 | @java.lang.Override 1796 | public int getSerializedSize() { 1797 | int size = memoizedSize; 1798 | if (size != -1) return size; 1799 | 1800 | size = 0; 1801 | if (!getNameBytes().isEmpty()) { 1802 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); 1803 | } 1804 | if (age_ != 0) { 1805 | size += com.google.protobuf.CodedOutputStream 1806 | .computeInt32Size(2, age_); 1807 | } 1808 | size += unknownFields.getSerializedSize(); 1809 | memoizedSize = size; 1810 | return size; 1811 | } 1812 | 1813 | @java.lang.Override 1814 | public boolean equals(final java.lang.Object obj) { 1815 | if (obj == this) { 1816 | return true; 1817 | } 1818 | if (!(obj instanceof com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog)) { 1819 | return super.equals(obj); 1820 | } 1821 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog other = (com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog) obj; 1822 | 1823 | if (!getName() 1824 | .equals(other.getName())) return false; 1825 | if (getAge() 1826 | != other.getAge()) return false; 1827 | if (!unknownFields.equals(other.unknownFields)) return false; 1828 | return true; 1829 | } 1830 | 1831 | @java.lang.Override 1832 | public int hashCode() { 1833 | if (memoizedHashCode != 0) { 1834 | return memoizedHashCode; 1835 | } 1836 | int hash = 41; 1837 | hash = (19 * hash) + getDescriptor().hashCode(); 1838 | hash = (37 * hash) + NAME_FIELD_NUMBER; 1839 | hash = (53 * hash) + getName().hashCode(); 1840 | hash = (37 * hash) + AGE_FIELD_NUMBER; 1841 | hash = (53 * hash) + getAge(); 1842 | hash = (29 * hash) + unknownFields.hashCode(); 1843 | memoizedHashCode = hash; 1844 | return hash; 1845 | } 1846 | 1847 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1848 | java.nio.ByteBuffer data) 1849 | throws com.google.protobuf.InvalidProtocolBufferException { 1850 | return PARSER.parseFrom(data); 1851 | } 1852 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1853 | java.nio.ByteBuffer data, 1854 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1855 | throws com.google.protobuf.InvalidProtocolBufferException { 1856 | return PARSER.parseFrom(data, extensionRegistry); 1857 | } 1858 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1859 | com.google.protobuf.ByteString data) 1860 | throws com.google.protobuf.InvalidProtocolBufferException { 1861 | return PARSER.parseFrom(data); 1862 | } 1863 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1864 | com.google.protobuf.ByteString data, 1865 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1866 | throws com.google.protobuf.InvalidProtocolBufferException { 1867 | return PARSER.parseFrom(data, extensionRegistry); 1868 | } 1869 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom(byte[] data) 1870 | throws com.google.protobuf.InvalidProtocolBufferException { 1871 | return PARSER.parseFrom(data); 1872 | } 1873 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1874 | byte[] data, 1875 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1876 | throws com.google.protobuf.InvalidProtocolBufferException { 1877 | return PARSER.parseFrom(data, extensionRegistry); 1878 | } 1879 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom(java.io.InputStream input) 1880 | throws java.io.IOException { 1881 | return com.google.protobuf.GeneratedMessageV3 1882 | .parseWithIOException(PARSER, input); 1883 | } 1884 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1885 | java.io.InputStream input, 1886 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1887 | throws java.io.IOException { 1888 | return com.google.protobuf.GeneratedMessageV3 1889 | .parseWithIOException(PARSER, input, extensionRegistry); 1890 | } 1891 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseDelimitedFrom(java.io.InputStream input) 1892 | throws java.io.IOException { 1893 | return com.google.protobuf.GeneratedMessageV3 1894 | .parseDelimitedWithIOException(PARSER, input); 1895 | } 1896 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseDelimitedFrom( 1897 | java.io.InputStream input, 1898 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1899 | throws java.io.IOException { 1900 | return com.google.protobuf.GeneratedMessageV3 1901 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 1902 | } 1903 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1904 | com.google.protobuf.CodedInputStream input) 1905 | throws java.io.IOException { 1906 | return com.google.protobuf.GeneratedMessageV3 1907 | .parseWithIOException(PARSER, input); 1908 | } 1909 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parseFrom( 1910 | com.google.protobuf.CodedInputStream input, 1911 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1912 | throws java.io.IOException { 1913 | return com.google.protobuf.GeneratedMessageV3 1914 | .parseWithIOException(PARSER, input, extensionRegistry); 1915 | } 1916 | 1917 | @java.lang.Override 1918 | public Builder newBuilderForType() { return newBuilder(); } 1919 | public static Builder newBuilder() { 1920 | return DEFAULT_INSTANCE.toBuilder(); 1921 | } 1922 | public static Builder newBuilder(com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog prototype) { 1923 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 1924 | } 1925 | @java.lang.Override 1926 | public Builder toBuilder() { 1927 | return this == DEFAULT_INSTANCE 1928 | ? new Builder() : new Builder().mergeFrom(this); 1929 | } 1930 | 1931 | @java.lang.Override 1932 | protected Builder newBuilderForType( 1933 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1934 | Builder builder = new Builder(parent); 1935 | return builder; 1936 | } 1937 | /** 1938 | * Protobuf type {@code Dog} 1939 | */ 1940 | public static final class Builder extends 1941 | com.google.protobuf.GeneratedMessageV3.Builder implements 1942 | // @@protoc_insertion_point(builder_implements:Dog) 1943 | com.fengfshao.dynamicproto.pb3.MultiplePerson.DogOrBuilder { 1944 | public static final com.google.protobuf.Descriptors.Descriptor 1945 | getDescriptor() { 1946 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_Dog_descriptor; 1947 | } 1948 | 1949 | @java.lang.Override 1950 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1951 | internalGetFieldAccessorTable() { 1952 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_Dog_fieldAccessorTable 1953 | .ensureFieldAccessorsInitialized( 1954 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.class, com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.Builder.class); 1955 | } 1956 | 1957 | // Construct using com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.newBuilder() 1958 | private Builder() { 1959 | maybeForceBuilderInitialization(); 1960 | } 1961 | 1962 | private Builder( 1963 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1964 | super(parent); 1965 | maybeForceBuilderInitialization(); 1966 | } 1967 | private void maybeForceBuilderInitialization() { 1968 | if (com.google.protobuf.GeneratedMessageV3 1969 | .alwaysUseFieldBuilders) { 1970 | } 1971 | } 1972 | @java.lang.Override 1973 | public Builder clear() { 1974 | super.clear(); 1975 | name_ = ""; 1976 | 1977 | age_ = 0; 1978 | 1979 | return this; 1980 | } 1981 | 1982 | @java.lang.Override 1983 | public com.google.protobuf.Descriptors.Descriptor 1984 | getDescriptorForType() { 1985 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.internal_static_Dog_descriptor; 1986 | } 1987 | 1988 | @java.lang.Override 1989 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getDefaultInstanceForType() { 1990 | return com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.getDefaultInstance(); 1991 | } 1992 | 1993 | @java.lang.Override 1994 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog build() { 1995 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog result = buildPartial(); 1996 | if (!result.isInitialized()) { 1997 | throw newUninitializedMessageException(result); 1998 | } 1999 | return result; 2000 | } 2001 | 2002 | @java.lang.Override 2003 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog buildPartial() { 2004 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog result = new com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog(this); 2005 | result.name_ = name_; 2006 | result.age_ = age_; 2007 | onBuilt(); 2008 | return result; 2009 | } 2010 | 2011 | @java.lang.Override 2012 | public Builder clone() { 2013 | return super.clone(); 2014 | } 2015 | @java.lang.Override 2016 | public Builder setField( 2017 | com.google.protobuf.Descriptors.FieldDescriptor field, 2018 | java.lang.Object value) { 2019 | return super.setField(field, value); 2020 | } 2021 | @java.lang.Override 2022 | public Builder clearField( 2023 | com.google.protobuf.Descriptors.FieldDescriptor field) { 2024 | return super.clearField(field); 2025 | } 2026 | @java.lang.Override 2027 | public Builder clearOneof( 2028 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 2029 | return super.clearOneof(oneof); 2030 | } 2031 | @java.lang.Override 2032 | public Builder setRepeatedField( 2033 | com.google.protobuf.Descriptors.FieldDescriptor field, 2034 | int index, java.lang.Object value) { 2035 | return super.setRepeatedField(field, index, value); 2036 | } 2037 | @java.lang.Override 2038 | public Builder addRepeatedField( 2039 | com.google.protobuf.Descriptors.FieldDescriptor field, 2040 | java.lang.Object value) { 2041 | return super.addRepeatedField(field, value); 2042 | } 2043 | @java.lang.Override 2044 | public Builder mergeFrom(com.google.protobuf.Message other) { 2045 | if (other instanceof com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog) { 2046 | return mergeFrom((com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog)other); 2047 | } else { 2048 | super.mergeFrom(other); 2049 | return this; 2050 | } 2051 | } 2052 | 2053 | public Builder mergeFrom(com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog other) { 2054 | if (other == com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog.getDefaultInstance()) return this; 2055 | if (!other.getName().isEmpty()) { 2056 | name_ = other.name_; 2057 | onChanged(); 2058 | } 2059 | if (other.getAge() != 0) { 2060 | setAge(other.getAge()); 2061 | } 2062 | this.mergeUnknownFields(other.unknownFields); 2063 | onChanged(); 2064 | return this; 2065 | } 2066 | 2067 | @java.lang.Override 2068 | public final boolean isInitialized() { 2069 | return true; 2070 | } 2071 | 2072 | @java.lang.Override 2073 | public Builder mergeFrom( 2074 | com.google.protobuf.CodedInputStream input, 2075 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 2076 | throws java.io.IOException { 2077 | com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog parsedMessage = null; 2078 | try { 2079 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 2080 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 2081 | parsedMessage = (com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog) e.getUnfinishedMessage(); 2082 | throw e.unwrapIOException(); 2083 | } finally { 2084 | if (parsedMessage != null) { 2085 | mergeFrom(parsedMessage); 2086 | } 2087 | } 2088 | return this; 2089 | } 2090 | 2091 | private java.lang.Object name_ = ""; 2092 | /** 2093 | * string name = 1; 2094 | * @return The name. 2095 | */ 2096 | public java.lang.String getName() { 2097 | java.lang.Object ref = name_; 2098 | if (!(ref instanceof java.lang.String)) { 2099 | com.google.protobuf.ByteString bs = 2100 | (com.google.protobuf.ByteString) ref; 2101 | java.lang.String s = bs.toStringUtf8(); 2102 | name_ = s; 2103 | return s; 2104 | } else { 2105 | return (java.lang.String) ref; 2106 | } 2107 | } 2108 | /** 2109 | * string name = 1; 2110 | * @return The bytes for name. 2111 | */ 2112 | public com.google.protobuf.ByteString 2113 | getNameBytes() { 2114 | java.lang.Object ref = name_; 2115 | if (ref instanceof String) { 2116 | com.google.protobuf.ByteString b = 2117 | com.google.protobuf.ByteString.copyFromUtf8( 2118 | (java.lang.String) ref); 2119 | name_ = b; 2120 | return b; 2121 | } else { 2122 | return (com.google.protobuf.ByteString) ref; 2123 | } 2124 | } 2125 | /** 2126 | * string name = 1; 2127 | * @param value The name to set. 2128 | * @return This builder for chaining. 2129 | */ 2130 | public Builder setName( 2131 | java.lang.String value) { 2132 | if (value == null) { 2133 | throw new NullPointerException(); 2134 | } 2135 | 2136 | name_ = value; 2137 | onChanged(); 2138 | return this; 2139 | } 2140 | /** 2141 | * string name = 1; 2142 | * @return This builder for chaining. 2143 | */ 2144 | public Builder clearName() { 2145 | 2146 | name_ = getDefaultInstance().getName(); 2147 | onChanged(); 2148 | return this; 2149 | } 2150 | /** 2151 | * string name = 1; 2152 | * @param value The bytes for name to set. 2153 | * @return This builder for chaining. 2154 | */ 2155 | public Builder setNameBytes( 2156 | com.google.protobuf.ByteString value) { 2157 | if (value == null) { 2158 | throw new NullPointerException(); 2159 | } 2160 | checkByteStringIsUtf8(value); 2161 | 2162 | name_ = value; 2163 | onChanged(); 2164 | return this; 2165 | } 2166 | 2167 | private int age_ ; 2168 | /** 2169 | * int32 age = 2; 2170 | * @return The age. 2171 | */ 2172 | @java.lang.Override 2173 | public int getAge() { 2174 | return age_; 2175 | } 2176 | /** 2177 | * int32 age = 2; 2178 | * @param value The age to set. 2179 | * @return This builder for chaining. 2180 | */ 2181 | public Builder setAge(int value) { 2182 | 2183 | age_ = value; 2184 | onChanged(); 2185 | return this; 2186 | } 2187 | /** 2188 | * int32 age = 2; 2189 | * @return This builder for chaining. 2190 | */ 2191 | public Builder clearAge() { 2192 | 2193 | age_ = 0; 2194 | onChanged(); 2195 | return this; 2196 | } 2197 | @java.lang.Override 2198 | public final Builder setUnknownFields( 2199 | final com.google.protobuf.UnknownFieldSet unknownFields) { 2200 | return super.setUnknownFields(unknownFields); 2201 | } 2202 | 2203 | @java.lang.Override 2204 | public final Builder mergeUnknownFields( 2205 | final com.google.protobuf.UnknownFieldSet unknownFields) { 2206 | return super.mergeUnknownFields(unknownFields); 2207 | } 2208 | 2209 | 2210 | // @@protoc_insertion_point(builder_scope:Dog) 2211 | } 2212 | 2213 | // @@protoc_insertion_point(class_scope:Dog) 2214 | private static final com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog DEFAULT_INSTANCE; 2215 | static { 2216 | DEFAULT_INSTANCE = new com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog(); 2217 | } 2218 | 2219 | public static com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getDefaultInstance() { 2220 | return DEFAULT_INSTANCE; 2221 | } 2222 | 2223 | private static final com.google.protobuf.Parser 2224 | PARSER = new com.google.protobuf.AbstractParser() { 2225 | @java.lang.Override 2226 | public Dog parsePartialFrom( 2227 | com.google.protobuf.CodedInputStream input, 2228 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 2229 | throws com.google.protobuf.InvalidProtocolBufferException { 2230 | return new Dog(input, extensionRegistry); 2231 | } 2232 | }; 2233 | 2234 | public static com.google.protobuf.Parser parser() { 2235 | return PARSER; 2236 | } 2237 | 2238 | @java.lang.Override 2239 | public com.google.protobuf.Parser getParserForType() { 2240 | return PARSER; 2241 | } 2242 | 2243 | @java.lang.Override 2244 | public com.fengfshao.dynamicproto.pb3.MultiplePerson.Dog getDefaultInstanceForType() { 2245 | return DEFAULT_INSTANCE; 2246 | } 2247 | 2248 | } 2249 | 2250 | private static final com.google.protobuf.Descriptors.Descriptor 2251 | internal_static_MultiplePersonMessage_descriptor; 2252 | private static final 2253 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 2254 | internal_static_MultiplePersonMessage_fieldAccessorTable; 2255 | private static final com.google.protobuf.Descriptors.Descriptor 2256 | internal_static_Dog_descriptor; 2257 | private static final 2258 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 2259 | internal_static_Dog_fieldAccessorTable; 2260 | 2261 | public static com.google.protobuf.Descriptors.FileDescriptor 2262 | getDescriptor() { 2263 | return descriptor; 2264 | } 2265 | private static com.google.protobuf.Descriptors.FileDescriptor 2266 | descriptor; 2267 | static { 2268 | java.lang.String[] descriptorData = { 2269 | "\n\025multiple_person.proto\"~\n\025MultiplePerso" + 2270 | "nMessage\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030\002 \001(\t\022\027\n\006ge" + 2271 | "nder\030\003 \001(\0162\007.Gender\022\r\n\005email\030\004 \001(\t\022\017\n\007ad" + 2272 | "dress\030\005 \003(\t\022\022\n\004pets\030\006 \003(\0132\004.Dog\" \n\003Dog\022\014" + 2273 | "\n\004name\030\001 \001(\t\022\013\n\003age\030\002 \001(\005*\036\n\006Gender\022\010\n\004M" + 2274 | "ALE\020\000\022\n\n\006FEMALE\020\001B0\n\036com.fengfshao.dynam" + 2275 | "icproto.pb3B\016MultiplePersonb\006proto3" 2276 | }; 2277 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 2278 | .internalBuildGeneratedFileFrom(descriptorData, 2279 | new com.google.protobuf.Descriptors.FileDescriptor[] { 2280 | }); 2281 | internal_static_MultiplePersonMessage_descriptor = 2282 | getDescriptor().getMessageTypes().get(0); 2283 | internal_static_MultiplePersonMessage_fieldAccessorTable = new 2284 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 2285 | internal_static_MultiplePersonMessage_descriptor, 2286 | new java.lang.String[] { "Id", "Name", "Gender", "Email", "Address", "Pets", }); 2287 | internal_static_Dog_descriptor = 2288 | getDescriptor().getMessageTypes().get(1); 2289 | internal_static_Dog_fieldAccessorTable = new 2290 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 2291 | internal_static_Dog_descriptor, 2292 | new java.lang.String[] { "Name", "Age", }); 2293 | } 2294 | 2295 | // @@protoc_insertion_point(outer_class_scope) 2296 | } 2297 | -------------------------------------------------------------------------------- /src/test/java/com/fengfshao/dynamicproto/pb3/SimplePerson.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: simple_person.proto 3 | 4 | package com.fengfshao.dynamicproto.pb3; 5 | 6 | public final class SimplePerson { 7 | private SimplePerson() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface SimplePersonMessageOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:SimplePersonMessage) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | * int32 id = 1; 23 | * @return The id. 24 | */ 25 | int getId(); 26 | 27 | /** 28 | * string name = 2; 29 | * @return The name. 30 | */ 31 | java.lang.String getName(); 32 | /** 33 | * string name = 2; 34 | * @return The bytes for name. 35 | */ 36 | com.google.protobuf.ByteString 37 | getNameBytes(); 38 | 39 | /** 40 | * string email = 3; 41 | * @return The email. 42 | */ 43 | java.lang.String getEmail(); 44 | /** 45 | * string email = 3; 46 | * @return The bytes for email. 47 | */ 48 | com.google.protobuf.ByteString 49 | getEmailBytes(); 50 | 51 | /** 52 | * repeated string address = 4; 53 | * @return A list containing the address. 54 | */ 55 | java.util.List 56 | getAddressList(); 57 | /** 58 | * repeated string address = 4; 59 | * @return The count of address. 60 | */ 61 | int getAddressCount(); 62 | /** 63 | * repeated string address = 4; 64 | * @param index The index of the element to return. 65 | * @return The address at the given index. 66 | */ 67 | java.lang.String getAddress(int index); 68 | /** 69 | * repeated string address = 4; 70 | * @param index The index of the value to return. 71 | * @return The bytes of the address at the given index. 72 | */ 73 | com.google.protobuf.ByteString 74 | getAddressBytes(int index); 75 | } 76 | /** 77 | * Protobuf type {@code SimplePersonMessage} 78 | */ 79 | public static final class SimplePersonMessage extends 80 | com.google.protobuf.GeneratedMessageV3 implements 81 | // @@protoc_insertion_point(message_implements:SimplePersonMessage) 82 | SimplePersonMessageOrBuilder { 83 | private static final long serialVersionUID = 0L; 84 | // Use SimplePersonMessage.newBuilder() to construct. 85 | private SimplePersonMessage(com.google.protobuf.GeneratedMessageV3.Builder builder) { 86 | super(builder); 87 | } 88 | private SimplePersonMessage() { 89 | name_ = ""; 90 | email_ = ""; 91 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 92 | } 93 | 94 | @java.lang.Override 95 | @SuppressWarnings({"unused"}) 96 | protected java.lang.Object newInstance( 97 | UnusedPrivateParameter unused) { 98 | return new SimplePersonMessage(); 99 | } 100 | 101 | @java.lang.Override 102 | public final com.google.protobuf.UnknownFieldSet 103 | getUnknownFields() { 104 | return this.unknownFields; 105 | } 106 | private SimplePersonMessage( 107 | com.google.protobuf.CodedInputStream input, 108 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 109 | throws com.google.protobuf.InvalidProtocolBufferException { 110 | this(); 111 | if (extensionRegistry == null) { 112 | throw new java.lang.NullPointerException(); 113 | } 114 | int mutable_bitField0_ = 0; 115 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 116 | com.google.protobuf.UnknownFieldSet.newBuilder(); 117 | try { 118 | boolean done = false; 119 | while (!done) { 120 | int tag = input.readTag(); 121 | switch (tag) { 122 | case 0: 123 | done = true; 124 | break; 125 | case 8: { 126 | 127 | id_ = input.readInt32(); 128 | break; 129 | } 130 | case 18: { 131 | java.lang.String s = input.readStringRequireUtf8(); 132 | 133 | name_ = s; 134 | break; 135 | } 136 | case 26: { 137 | java.lang.String s = input.readStringRequireUtf8(); 138 | 139 | email_ = s; 140 | break; 141 | } 142 | case 34: { 143 | java.lang.String s = input.readStringRequireUtf8(); 144 | if (!((mutable_bitField0_ & 0x00000001) != 0)) { 145 | address_ = new com.google.protobuf.LazyStringArrayList(); 146 | mutable_bitField0_ |= 0x00000001; 147 | } 148 | address_.add(s); 149 | break; 150 | } 151 | default: { 152 | if (!parseUnknownField( 153 | input, unknownFields, extensionRegistry, tag)) { 154 | done = true; 155 | } 156 | break; 157 | } 158 | } 159 | } 160 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 161 | throw e.setUnfinishedMessage(this); 162 | } catch (java.io.IOException e) { 163 | throw new com.google.protobuf.InvalidProtocolBufferException( 164 | e).setUnfinishedMessage(this); 165 | } finally { 166 | if (((mutable_bitField0_ & 0x00000001) != 0)) { 167 | address_ = address_.getUnmodifiableView(); 168 | } 169 | this.unknownFields = unknownFields.build(); 170 | makeExtensionsImmutable(); 171 | } 172 | } 173 | public static final com.google.protobuf.Descriptors.Descriptor 174 | getDescriptor() { 175 | return com.fengfshao.dynamicproto.pb3.SimplePerson.internal_static_SimplePersonMessage_descriptor; 176 | } 177 | 178 | @java.lang.Override 179 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 180 | internalGetFieldAccessorTable() { 181 | return com.fengfshao.dynamicproto.pb3.SimplePerson.internal_static_SimplePersonMessage_fieldAccessorTable 182 | .ensureFieldAccessorsInitialized( 183 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.class, com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.Builder.class); 184 | } 185 | 186 | public static final int ID_FIELD_NUMBER = 1; 187 | private int id_; 188 | /** 189 | * int32 id = 1; 190 | * @return The id. 191 | */ 192 | @java.lang.Override 193 | public int getId() { 194 | return id_; 195 | } 196 | 197 | public static final int NAME_FIELD_NUMBER = 2; 198 | private volatile java.lang.Object name_; 199 | /** 200 | * string name = 2; 201 | * @return The name. 202 | */ 203 | @java.lang.Override 204 | public java.lang.String getName() { 205 | java.lang.Object ref = name_; 206 | if (ref instanceof java.lang.String) { 207 | return (java.lang.String) ref; 208 | } else { 209 | com.google.protobuf.ByteString bs = 210 | (com.google.protobuf.ByteString) ref; 211 | java.lang.String s = bs.toStringUtf8(); 212 | name_ = s; 213 | return s; 214 | } 215 | } 216 | /** 217 | * string name = 2; 218 | * @return The bytes for name. 219 | */ 220 | @java.lang.Override 221 | public com.google.protobuf.ByteString 222 | getNameBytes() { 223 | java.lang.Object ref = name_; 224 | if (ref instanceof java.lang.String) { 225 | com.google.protobuf.ByteString b = 226 | com.google.protobuf.ByteString.copyFromUtf8( 227 | (java.lang.String) ref); 228 | name_ = b; 229 | return b; 230 | } else { 231 | return (com.google.protobuf.ByteString) ref; 232 | } 233 | } 234 | 235 | public static final int EMAIL_FIELD_NUMBER = 3; 236 | private volatile java.lang.Object email_; 237 | /** 238 | * string email = 3; 239 | * @return The email. 240 | */ 241 | @java.lang.Override 242 | public java.lang.String getEmail() { 243 | java.lang.Object ref = email_; 244 | if (ref instanceof java.lang.String) { 245 | return (java.lang.String) ref; 246 | } else { 247 | com.google.protobuf.ByteString bs = 248 | (com.google.protobuf.ByteString) ref; 249 | java.lang.String s = bs.toStringUtf8(); 250 | email_ = s; 251 | return s; 252 | } 253 | } 254 | /** 255 | * string email = 3; 256 | * @return The bytes for email. 257 | */ 258 | @java.lang.Override 259 | public com.google.protobuf.ByteString 260 | getEmailBytes() { 261 | java.lang.Object ref = email_; 262 | if (ref instanceof java.lang.String) { 263 | com.google.protobuf.ByteString b = 264 | com.google.protobuf.ByteString.copyFromUtf8( 265 | (java.lang.String) ref); 266 | email_ = b; 267 | return b; 268 | } else { 269 | return (com.google.protobuf.ByteString) ref; 270 | } 271 | } 272 | 273 | public static final int ADDRESS_FIELD_NUMBER = 4; 274 | private com.google.protobuf.LazyStringList address_; 275 | /** 276 | * repeated string address = 4; 277 | * @return A list containing the address. 278 | */ 279 | public com.google.protobuf.ProtocolStringList 280 | getAddressList() { 281 | return address_; 282 | } 283 | /** 284 | * repeated string address = 4; 285 | * @return The count of address. 286 | */ 287 | public int getAddressCount() { 288 | return address_.size(); 289 | } 290 | /** 291 | * repeated string address = 4; 292 | * @param index The index of the element to return. 293 | * @return The address at the given index. 294 | */ 295 | public java.lang.String getAddress(int index) { 296 | return address_.get(index); 297 | } 298 | /** 299 | * repeated string address = 4; 300 | * @param index The index of the value to return. 301 | * @return The bytes of the address at the given index. 302 | */ 303 | public com.google.protobuf.ByteString 304 | getAddressBytes(int index) { 305 | return address_.getByteString(index); 306 | } 307 | 308 | private byte memoizedIsInitialized = -1; 309 | @java.lang.Override 310 | public final boolean isInitialized() { 311 | byte isInitialized = memoizedIsInitialized; 312 | if (isInitialized == 1) return true; 313 | if (isInitialized == 0) return false; 314 | 315 | memoizedIsInitialized = 1; 316 | return true; 317 | } 318 | 319 | @java.lang.Override 320 | public void writeTo(com.google.protobuf.CodedOutputStream output) 321 | throws java.io.IOException { 322 | if (id_ != 0) { 323 | output.writeInt32(1, id_); 324 | } 325 | if (!getNameBytes().isEmpty()) { 326 | com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); 327 | } 328 | if (!getEmailBytes().isEmpty()) { 329 | com.google.protobuf.GeneratedMessageV3.writeString(output, 3, email_); 330 | } 331 | for (int i = 0; i < address_.size(); i++) { 332 | com.google.protobuf.GeneratedMessageV3.writeString(output, 4, address_.getRaw(i)); 333 | } 334 | unknownFields.writeTo(output); 335 | } 336 | 337 | @java.lang.Override 338 | public int getSerializedSize() { 339 | int size = memoizedSize; 340 | if (size != -1) return size; 341 | 342 | size = 0; 343 | if (id_ != 0) { 344 | size += com.google.protobuf.CodedOutputStream 345 | .computeInt32Size(1, id_); 346 | } 347 | if (!getNameBytes().isEmpty()) { 348 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); 349 | } 350 | if (!getEmailBytes().isEmpty()) { 351 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, email_); 352 | } 353 | { 354 | int dataSize = 0; 355 | for (int i = 0; i < address_.size(); i++) { 356 | dataSize += computeStringSizeNoTag(address_.getRaw(i)); 357 | } 358 | size += dataSize; 359 | size += 1 * getAddressList().size(); 360 | } 361 | size += unknownFields.getSerializedSize(); 362 | memoizedSize = size; 363 | return size; 364 | } 365 | 366 | @java.lang.Override 367 | public boolean equals(final java.lang.Object obj) { 368 | if (obj == this) { 369 | return true; 370 | } 371 | if (!(obj instanceof com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage)) { 372 | return super.equals(obj); 373 | } 374 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage other = (com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage) obj; 375 | 376 | if (getId() 377 | != other.getId()) return false; 378 | if (!getName() 379 | .equals(other.getName())) return false; 380 | if (!getEmail() 381 | .equals(other.getEmail())) return false; 382 | if (!getAddressList() 383 | .equals(other.getAddressList())) return false; 384 | if (!unknownFields.equals(other.unknownFields)) return false; 385 | return true; 386 | } 387 | 388 | @java.lang.Override 389 | public int hashCode() { 390 | if (memoizedHashCode != 0) { 391 | return memoizedHashCode; 392 | } 393 | int hash = 41; 394 | hash = (19 * hash) + getDescriptor().hashCode(); 395 | hash = (37 * hash) + ID_FIELD_NUMBER; 396 | hash = (53 * hash) + getId(); 397 | hash = (37 * hash) + NAME_FIELD_NUMBER; 398 | hash = (53 * hash) + getName().hashCode(); 399 | hash = (37 * hash) + EMAIL_FIELD_NUMBER; 400 | hash = (53 * hash) + getEmail().hashCode(); 401 | if (getAddressCount() > 0) { 402 | hash = (37 * hash) + ADDRESS_FIELD_NUMBER; 403 | hash = (53 * hash) + getAddressList().hashCode(); 404 | } 405 | hash = (29 * hash) + unknownFields.hashCode(); 406 | memoizedHashCode = hash; 407 | return hash; 408 | } 409 | 410 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 411 | java.nio.ByteBuffer data) 412 | throws com.google.protobuf.InvalidProtocolBufferException { 413 | return PARSER.parseFrom(data); 414 | } 415 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 416 | java.nio.ByteBuffer data, 417 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 418 | throws com.google.protobuf.InvalidProtocolBufferException { 419 | return PARSER.parseFrom(data, extensionRegistry); 420 | } 421 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 422 | com.google.protobuf.ByteString data) 423 | throws com.google.protobuf.InvalidProtocolBufferException { 424 | return PARSER.parseFrom(data); 425 | } 426 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 427 | com.google.protobuf.ByteString data, 428 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 429 | throws com.google.protobuf.InvalidProtocolBufferException { 430 | return PARSER.parseFrom(data, extensionRegistry); 431 | } 432 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom(byte[] data) 433 | throws com.google.protobuf.InvalidProtocolBufferException { 434 | return PARSER.parseFrom(data); 435 | } 436 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 437 | byte[] data, 438 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 439 | throws com.google.protobuf.InvalidProtocolBufferException { 440 | return PARSER.parseFrom(data, extensionRegistry); 441 | } 442 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom(java.io.InputStream input) 443 | throws java.io.IOException { 444 | return com.google.protobuf.GeneratedMessageV3 445 | .parseWithIOException(PARSER, input); 446 | } 447 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 448 | java.io.InputStream input, 449 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 450 | throws java.io.IOException { 451 | return com.google.protobuf.GeneratedMessageV3 452 | .parseWithIOException(PARSER, input, extensionRegistry); 453 | } 454 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseDelimitedFrom(java.io.InputStream input) 455 | throws java.io.IOException { 456 | return com.google.protobuf.GeneratedMessageV3 457 | .parseDelimitedWithIOException(PARSER, input); 458 | } 459 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseDelimitedFrom( 460 | java.io.InputStream input, 461 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 462 | throws java.io.IOException { 463 | return com.google.protobuf.GeneratedMessageV3 464 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 465 | } 466 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 467 | com.google.protobuf.CodedInputStream input) 468 | throws java.io.IOException { 469 | return com.google.protobuf.GeneratedMessageV3 470 | .parseWithIOException(PARSER, input); 471 | } 472 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parseFrom( 473 | com.google.protobuf.CodedInputStream input, 474 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 475 | throws java.io.IOException { 476 | return com.google.protobuf.GeneratedMessageV3 477 | .parseWithIOException(PARSER, input, extensionRegistry); 478 | } 479 | 480 | @java.lang.Override 481 | public Builder newBuilderForType() { return newBuilder(); } 482 | public static Builder newBuilder() { 483 | return DEFAULT_INSTANCE.toBuilder(); 484 | } 485 | public static Builder newBuilder(com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage prototype) { 486 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 487 | } 488 | @java.lang.Override 489 | public Builder toBuilder() { 490 | return this == DEFAULT_INSTANCE 491 | ? new Builder() : new Builder().mergeFrom(this); 492 | } 493 | 494 | @java.lang.Override 495 | protected Builder newBuilderForType( 496 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 497 | Builder builder = new Builder(parent); 498 | return builder; 499 | } 500 | /** 501 | * Protobuf type {@code SimplePersonMessage} 502 | */ 503 | public static final class Builder extends 504 | com.google.protobuf.GeneratedMessageV3.Builder implements 505 | // @@protoc_insertion_point(builder_implements:SimplePersonMessage) 506 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessageOrBuilder { 507 | public static final com.google.protobuf.Descriptors.Descriptor 508 | getDescriptor() { 509 | return com.fengfshao.dynamicproto.pb3.SimplePerson.internal_static_SimplePersonMessage_descriptor; 510 | } 511 | 512 | @java.lang.Override 513 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 514 | internalGetFieldAccessorTable() { 515 | return com.fengfshao.dynamicproto.pb3.SimplePerson.internal_static_SimplePersonMessage_fieldAccessorTable 516 | .ensureFieldAccessorsInitialized( 517 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.class, com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.Builder.class); 518 | } 519 | 520 | // Construct using com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.newBuilder() 521 | private Builder() { 522 | maybeForceBuilderInitialization(); 523 | } 524 | 525 | private Builder( 526 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 527 | super(parent); 528 | maybeForceBuilderInitialization(); 529 | } 530 | private void maybeForceBuilderInitialization() { 531 | if (com.google.protobuf.GeneratedMessageV3 532 | .alwaysUseFieldBuilders) { 533 | } 534 | } 535 | @java.lang.Override 536 | public Builder clear() { 537 | super.clear(); 538 | id_ = 0; 539 | 540 | name_ = ""; 541 | 542 | email_ = ""; 543 | 544 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 545 | bitField0_ = (bitField0_ & ~0x00000001); 546 | return this; 547 | } 548 | 549 | @java.lang.Override 550 | public com.google.protobuf.Descriptors.Descriptor 551 | getDescriptorForType() { 552 | return com.fengfshao.dynamicproto.pb3.SimplePerson.internal_static_SimplePersonMessage_descriptor; 553 | } 554 | 555 | @java.lang.Override 556 | public com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage getDefaultInstanceForType() { 557 | return com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.getDefaultInstance(); 558 | } 559 | 560 | @java.lang.Override 561 | public com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage build() { 562 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage result = buildPartial(); 563 | if (!result.isInitialized()) { 564 | throw newUninitializedMessageException(result); 565 | } 566 | return result; 567 | } 568 | 569 | @java.lang.Override 570 | public com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage buildPartial() { 571 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage result = new com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage(this); 572 | int from_bitField0_ = bitField0_; 573 | result.id_ = id_; 574 | result.name_ = name_; 575 | result.email_ = email_; 576 | if (((bitField0_ & 0x00000001) != 0)) { 577 | address_ = address_.getUnmodifiableView(); 578 | bitField0_ = (bitField0_ & ~0x00000001); 579 | } 580 | result.address_ = address_; 581 | onBuilt(); 582 | return result; 583 | } 584 | 585 | @java.lang.Override 586 | public Builder clone() { 587 | return super.clone(); 588 | } 589 | @java.lang.Override 590 | public Builder setField( 591 | com.google.protobuf.Descriptors.FieldDescriptor field, 592 | java.lang.Object value) { 593 | return super.setField(field, value); 594 | } 595 | @java.lang.Override 596 | public Builder clearField( 597 | com.google.protobuf.Descriptors.FieldDescriptor field) { 598 | return super.clearField(field); 599 | } 600 | @java.lang.Override 601 | public Builder clearOneof( 602 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 603 | return super.clearOneof(oneof); 604 | } 605 | @java.lang.Override 606 | public Builder setRepeatedField( 607 | com.google.protobuf.Descriptors.FieldDescriptor field, 608 | int index, java.lang.Object value) { 609 | return super.setRepeatedField(field, index, value); 610 | } 611 | @java.lang.Override 612 | public Builder addRepeatedField( 613 | com.google.protobuf.Descriptors.FieldDescriptor field, 614 | java.lang.Object value) { 615 | return super.addRepeatedField(field, value); 616 | } 617 | @java.lang.Override 618 | public Builder mergeFrom(com.google.protobuf.Message other) { 619 | if (other instanceof com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage) { 620 | return mergeFrom((com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage)other); 621 | } else { 622 | super.mergeFrom(other); 623 | return this; 624 | } 625 | } 626 | 627 | public Builder mergeFrom(com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage other) { 628 | if (other == com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage.getDefaultInstance()) return this; 629 | if (other.getId() != 0) { 630 | setId(other.getId()); 631 | } 632 | if (!other.getName().isEmpty()) { 633 | name_ = other.name_; 634 | onChanged(); 635 | } 636 | if (!other.getEmail().isEmpty()) { 637 | email_ = other.email_; 638 | onChanged(); 639 | } 640 | if (!other.address_.isEmpty()) { 641 | if (address_.isEmpty()) { 642 | address_ = other.address_; 643 | bitField0_ = (bitField0_ & ~0x00000001); 644 | } else { 645 | ensureAddressIsMutable(); 646 | address_.addAll(other.address_); 647 | } 648 | onChanged(); 649 | } 650 | this.mergeUnknownFields(other.unknownFields); 651 | onChanged(); 652 | return this; 653 | } 654 | 655 | @java.lang.Override 656 | public final boolean isInitialized() { 657 | return true; 658 | } 659 | 660 | @java.lang.Override 661 | public Builder mergeFrom( 662 | com.google.protobuf.CodedInputStream input, 663 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 664 | throws java.io.IOException { 665 | com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage parsedMessage = null; 666 | try { 667 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 668 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 669 | parsedMessage = (com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage) e.getUnfinishedMessage(); 670 | throw e.unwrapIOException(); 671 | } finally { 672 | if (parsedMessage != null) { 673 | mergeFrom(parsedMessage); 674 | } 675 | } 676 | return this; 677 | } 678 | private int bitField0_; 679 | 680 | private int id_ ; 681 | /** 682 | * int32 id = 1; 683 | * @return The id. 684 | */ 685 | @java.lang.Override 686 | public int getId() { 687 | return id_; 688 | } 689 | /** 690 | * int32 id = 1; 691 | * @param value The id to set. 692 | * @return This builder for chaining. 693 | */ 694 | public Builder setId(int value) { 695 | 696 | id_ = value; 697 | onChanged(); 698 | return this; 699 | } 700 | /** 701 | * int32 id = 1; 702 | * @return This builder for chaining. 703 | */ 704 | public Builder clearId() { 705 | 706 | id_ = 0; 707 | onChanged(); 708 | return this; 709 | } 710 | 711 | private java.lang.Object name_ = ""; 712 | /** 713 | * string name = 2; 714 | * @return The name. 715 | */ 716 | public java.lang.String getName() { 717 | java.lang.Object ref = name_; 718 | if (!(ref instanceof java.lang.String)) { 719 | com.google.protobuf.ByteString bs = 720 | (com.google.protobuf.ByteString) ref; 721 | java.lang.String s = bs.toStringUtf8(); 722 | name_ = s; 723 | return s; 724 | } else { 725 | return (java.lang.String) ref; 726 | } 727 | } 728 | /** 729 | * string name = 2; 730 | * @return The bytes for name. 731 | */ 732 | public com.google.protobuf.ByteString 733 | getNameBytes() { 734 | java.lang.Object ref = name_; 735 | if (ref instanceof String) { 736 | com.google.protobuf.ByteString b = 737 | com.google.protobuf.ByteString.copyFromUtf8( 738 | (java.lang.String) ref); 739 | name_ = b; 740 | return b; 741 | } else { 742 | return (com.google.protobuf.ByteString) ref; 743 | } 744 | } 745 | /** 746 | * string name = 2; 747 | * @param value The name to set. 748 | * @return This builder for chaining. 749 | */ 750 | public Builder setName( 751 | java.lang.String value) { 752 | if (value == null) { 753 | throw new NullPointerException(); 754 | } 755 | 756 | name_ = value; 757 | onChanged(); 758 | return this; 759 | } 760 | /** 761 | * string name = 2; 762 | * @return This builder for chaining. 763 | */ 764 | public Builder clearName() { 765 | 766 | name_ = getDefaultInstance().getName(); 767 | onChanged(); 768 | return this; 769 | } 770 | /** 771 | * string name = 2; 772 | * @param value The bytes for name to set. 773 | * @return This builder for chaining. 774 | */ 775 | public Builder setNameBytes( 776 | com.google.protobuf.ByteString value) { 777 | if (value == null) { 778 | throw new NullPointerException(); 779 | } 780 | checkByteStringIsUtf8(value); 781 | 782 | name_ = value; 783 | onChanged(); 784 | return this; 785 | } 786 | 787 | private java.lang.Object email_ = ""; 788 | /** 789 | * string email = 3; 790 | * @return The email. 791 | */ 792 | public java.lang.String getEmail() { 793 | java.lang.Object ref = email_; 794 | if (!(ref instanceof java.lang.String)) { 795 | com.google.protobuf.ByteString bs = 796 | (com.google.protobuf.ByteString) ref; 797 | java.lang.String s = bs.toStringUtf8(); 798 | email_ = s; 799 | return s; 800 | } else { 801 | return (java.lang.String) ref; 802 | } 803 | } 804 | /** 805 | * string email = 3; 806 | * @return The bytes for email. 807 | */ 808 | public com.google.protobuf.ByteString 809 | getEmailBytes() { 810 | java.lang.Object ref = email_; 811 | if (ref instanceof String) { 812 | com.google.protobuf.ByteString b = 813 | com.google.protobuf.ByteString.copyFromUtf8( 814 | (java.lang.String) ref); 815 | email_ = b; 816 | return b; 817 | } else { 818 | return (com.google.protobuf.ByteString) ref; 819 | } 820 | } 821 | /** 822 | * string email = 3; 823 | * @param value The email to set. 824 | * @return This builder for chaining. 825 | */ 826 | public Builder setEmail( 827 | java.lang.String value) { 828 | if (value == null) { 829 | throw new NullPointerException(); 830 | } 831 | 832 | email_ = value; 833 | onChanged(); 834 | return this; 835 | } 836 | /** 837 | * string email = 3; 838 | * @return This builder for chaining. 839 | */ 840 | public Builder clearEmail() { 841 | 842 | email_ = getDefaultInstance().getEmail(); 843 | onChanged(); 844 | return this; 845 | } 846 | /** 847 | * string email = 3; 848 | * @param value The bytes for email to set. 849 | * @return This builder for chaining. 850 | */ 851 | public Builder setEmailBytes( 852 | com.google.protobuf.ByteString value) { 853 | if (value == null) { 854 | throw new NullPointerException(); 855 | } 856 | checkByteStringIsUtf8(value); 857 | 858 | email_ = value; 859 | onChanged(); 860 | return this; 861 | } 862 | 863 | private com.google.protobuf.LazyStringList address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 864 | private void ensureAddressIsMutable() { 865 | if (!((bitField0_ & 0x00000001) != 0)) { 866 | address_ = new com.google.protobuf.LazyStringArrayList(address_); 867 | bitField0_ |= 0x00000001; 868 | } 869 | } 870 | /** 871 | * repeated string address = 4; 872 | * @return A list containing the address. 873 | */ 874 | public com.google.protobuf.ProtocolStringList 875 | getAddressList() { 876 | return address_.getUnmodifiableView(); 877 | } 878 | /** 879 | * repeated string address = 4; 880 | * @return The count of address. 881 | */ 882 | public int getAddressCount() { 883 | return address_.size(); 884 | } 885 | /** 886 | * repeated string address = 4; 887 | * @param index The index of the element to return. 888 | * @return The address at the given index. 889 | */ 890 | public java.lang.String getAddress(int index) { 891 | return address_.get(index); 892 | } 893 | /** 894 | * repeated string address = 4; 895 | * @param index The index of the value to return. 896 | * @return The bytes of the address at the given index. 897 | */ 898 | public com.google.protobuf.ByteString 899 | getAddressBytes(int index) { 900 | return address_.getByteString(index); 901 | } 902 | /** 903 | * repeated string address = 4; 904 | * @param index The index to set the value at. 905 | * @param value The address to set. 906 | * @return This builder for chaining. 907 | */ 908 | public Builder setAddress( 909 | int index, java.lang.String value) { 910 | if (value == null) { 911 | throw new NullPointerException(); 912 | } 913 | ensureAddressIsMutable(); 914 | address_.set(index, value); 915 | onChanged(); 916 | return this; 917 | } 918 | /** 919 | * repeated string address = 4; 920 | * @param value The address to add. 921 | * @return This builder for chaining. 922 | */ 923 | public Builder addAddress( 924 | java.lang.String value) { 925 | if (value == null) { 926 | throw new NullPointerException(); 927 | } 928 | ensureAddressIsMutable(); 929 | address_.add(value); 930 | onChanged(); 931 | return this; 932 | } 933 | /** 934 | * repeated string address = 4; 935 | * @param values The address to add. 936 | * @return This builder for chaining. 937 | */ 938 | public Builder addAllAddress( 939 | java.lang.Iterable values) { 940 | ensureAddressIsMutable(); 941 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 942 | values, address_); 943 | onChanged(); 944 | return this; 945 | } 946 | /** 947 | * repeated string address = 4; 948 | * @return This builder for chaining. 949 | */ 950 | public Builder clearAddress() { 951 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 952 | bitField0_ = (bitField0_ & ~0x00000001); 953 | onChanged(); 954 | return this; 955 | } 956 | /** 957 | * repeated string address = 4; 958 | * @param value The bytes of the address to add. 959 | * @return This builder for chaining. 960 | */ 961 | public Builder addAddressBytes( 962 | com.google.protobuf.ByteString value) { 963 | if (value == null) { 964 | throw new NullPointerException(); 965 | } 966 | checkByteStringIsUtf8(value); 967 | ensureAddressIsMutable(); 968 | address_.add(value); 969 | onChanged(); 970 | return this; 971 | } 972 | @java.lang.Override 973 | public final Builder setUnknownFields( 974 | final com.google.protobuf.UnknownFieldSet unknownFields) { 975 | return super.setUnknownFields(unknownFields); 976 | } 977 | 978 | @java.lang.Override 979 | public final Builder mergeUnknownFields( 980 | final com.google.protobuf.UnknownFieldSet unknownFields) { 981 | return super.mergeUnknownFields(unknownFields); 982 | } 983 | 984 | 985 | // @@protoc_insertion_point(builder_scope:SimplePersonMessage) 986 | } 987 | 988 | // @@protoc_insertion_point(class_scope:SimplePersonMessage) 989 | private static final com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage DEFAULT_INSTANCE; 990 | static { 991 | DEFAULT_INSTANCE = new com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage(); 992 | } 993 | 994 | public static com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage getDefaultInstance() { 995 | return DEFAULT_INSTANCE; 996 | } 997 | 998 | private static final com.google.protobuf.Parser 999 | PARSER = new com.google.protobuf.AbstractParser() { 1000 | @java.lang.Override 1001 | public SimplePersonMessage parsePartialFrom( 1002 | com.google.protobuf.CodedInputStream input, 1003 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1004 | throws com.google.protobuf.InvalidProtocolBufferException { 1005 | return new SimplePersonMessage(input, extensionRegistry); 1006 | } 1007 | }; 1008 | 1009 | public static com.google.protobuf.Parser parser() { 1010 | return PARSER; 1011 | } 1012 | 1013 | @java.lang.Override 1014 | public com.google.protobuf.Parser getParserForType() { 1015 | return PARSER; 1016 | } 1017 | 1018 | @java.lang.Override 1019 | public com.fengfshao.dynamicproto.pb3.SimplePerson.SimplePersonMessage getDefaultInstanceForType() { 1020 | return DEFAULT_INSTANCE; 1021 | } 1022 | 1023 | } 1024 | 1025 | private static final com.google.protobuf.Descriptors.Descriptor 1026 | internal_static_SimplePersonMessage_descriptor; 1027 | private static final 1028 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1029 | internal_static_SimplePersonMessage_fieldAccessorTable; 1030 | 1031 | public static com.google.protobuf.Descriptors.FileDescriptor 1032 | getDescriptor() { 1033 | return descriptor; 1034 | } 1035 | private static com.google.protobuf.Descriptors.FileDescriptor 1036 | descriptor; 1037 | static { 1038 | java.lang.String[] descriptorData = { 1039 | "\n\023simple_person.proto\"O\n\023SimplePersonMes" + 1040 | "sage\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030\002 \001(\t\022\r\n\005email\030" + 1041 | "\003 \001(\t\022\017\n\007address\030\004 \003(\tB.\n\036com.fengfshao." + 1042 | "dynamicproto.pb3B\014SimplePersonb\006proto3" 1043 | }; 1044 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 1045 | .internalBuildGeneratedFileFrom(descriptorData, 1046 | new com.google.protobuf.Descriptors.FileDescriptor[] { 1047 | }); 1048 | internal_static_SimplePersonMessage_descriptor = 1049 | getDescriptor().getMessageTypes().get(0); 1050 | internal_static_SimplePersonMessage_fieldAccessorTable = new 1051 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1052 | internal_static_SimplePersonMessage_descriptor, 1053 | new java.lang.String[] { "Id", "Name", "Email", "Address", }); 1054 | } 1055 | 1056 | // @@protoc_insertion_point(outer_class_scope) 1057 | } 1058 | -------------------------------------------------------------------------------- /src/test/java/com/fengfshao/dynamicproto/pb3/SimplePersonV2.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: simple_personv2.proto 3 | 4 | package com.fengfshao.dynamicproto.pb3; 5 | 6 | public final class SimplePersonV2 { 7 | private SimplePersonV2() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | /** 18 | * Protobuf enum {@code Gender} 19 | */ 20 | public enum Gender 21 | implements com.google.protobuf.ProtocolMessageEnum { 22 | /** 23 | * MALE = 0; 24 | */ 25 | MALE(0), 26 | /** 27 | * FEMALE = 1; 28 | */ 29 | FEMALE(1), 30 | UNRECOGNIZED(-1), 31 | ; 32 | 33 | /** 34 | * MALE = 0; 35 | */ 36 | public static final int MALE_VALUE = 0; 37 | /** 38 | * FEMALE = 1; 39 | */ 40 | public static final int FEMALE_VALUE = 1; 41 | 42 | 43 | public final int getNumber() { 44 | if (this == UNRECOGNIZED) { 45 | throw new java.lang.IllegalArgumentException( 46 | "Can't get the number of an unknown enum value."); 47 | } 48 | return value; 49 | } 50 | 51 | /** 52 | * @param value The numeric wire value of the corresponding enum entry. 53 | * @return The enum associated with the given numeric wire value. 54 | * @deprecated Use {@link #forNumber(int)} instead. 55 | */ 56 | @java.lang.Deprecated 57 | public static Gender valueOf(int value) { 58 | return forNumber(value); 59 | } 60 | 61 | /** 62 | * @param value The numeric wire value of the corresponding enum entry. 63 | * @return The enum associated with the given numeric wire value. 64 | */ 65 | public static Gender forNumber(int value) { 66 | switch (value) { 67 | case 0: return MALE; 68 | case 1: return FEMALE; 69 | default: return null; 70 | } 71 | } 72 | 73 | public static com.google.protobuf.Internal.EnumLiteMap 74 | internalGetValueMap() { 75 | return internalValueMap; 76 | } 77 | private static final com.google.protobuf.Internal.EnumLiteMap< 78 | Gender> internalValueMap = 79 | new com.google.protobuf.Internal.EnumLiteMap() { 80 | public Gender findValueByNumber(int number) { 81 | return Gender.forNumber(number); 82 | } 83 | }; 84 | 85 | public final com.google.protobuf.Descriptors.EnumValueDescriptor 86 | getValueDescriptor() { 87 | if (this == UNRECOGNIZED) { 88 | throw new java.lang.IllegalStateException( 89 | "Can't get the descriptor of an unrecognized enum value."); 90 | } 91 | return getDescriptor().getValues().get(ordinal()); 92 | } 93 | public final com.google.protobuf.Descriptors.EnumDescriptor 94 | getDescriptorForType() { 95 | return getDescriptor(); 96 | } 97 | public static final com.google.protobuf.Descriptors.EnumDescriptor 98 | getDescriptor() { 99 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.getDescriptor().getEnumTypes().get(0); 100 | } 101 | 102 | private static final Gender[] VALUES = values(); 103 | 104 | public static Gender valueOf( 105 | com.google.protobuf.Descriptors.EnumValueDescriptor desc) { 106 | if (desc.getType() != getDescriptor()) { 107 | throw new java.lang.IllegalArgumentException( 108 | "EnumValueDescriptor is not for this type."); 109 | } 110 | if (desc.getIndex() == -1) { 111 | return UNRECOGNIZED; 112 | } 113 | return VALUES[desc.getIndex()]; 114 | } 115 | 116 | private final int value; 117 | 118 | private Gender(int value) { 119 | this.value = value; 120 | } 121 | 122 | // @@protoc_insertion_point(enum_scope:Gender) 123 | } 124 | 125 | public interface SimplePersonMessageV2OrBuilder extends 126 | // @@protoc_insertion_point(interface_extends:SimplePersonMessageV2) 127 | com.google.protobuf.MessageOrBuilder { 128 | 129 | /** 130 | * int32 id = 1; 131 | * @return The id. 132 | */ 133 | int getId(); 134 | 135 | /** 136 | * string name = 2; 137 | * @return The name. 138 | */ 139 | java.lang.String getName(); 140 | /** 141 | * string name = 2; 142 | * @return The bytes for name. 143 | */ 144 | com.google.protobuf.ByteString 145 | getNameBytes(); 146 | 147 | /** 148 | * .Gender gender = 3; 149 | * @return The enum numeric value on the wire for gender. 150 | */ 151 | int getGenderValue(); 152 | /** 153 | * .Gender gender = 3; 154 | * @return The gender. 155 | */ 156 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender getGender(); 157 | 158 | /** 159 | * string email = 4; 160 | * @return The email. 161 | */ 162 | java.lang.String getEmail(); 163 | /** 164 | * string email = 4; 165 | * @return The bytes for email. 166 | */ 167 | com.google.protobuf.ByteString 168 | getEmailBytes(); 169 | 170 | /** 171 | * repeated string address = 5; 172 | * @return A list containing the address. 173 | */ 174 | java.util.List 175 | getAddressList(); 176 | /** 177 | * repeated string address = 5; 178 | * @return The count of address. 179 | */ 180 | int getAddressCount(); 181 | /** 182 | * repeated string address = 5; 183 | * @param index The index of the element to return. 184 | * @return The address at the given index. 185 | */ 186 | java.lang.String getAddress(int index); 187 | /** 188 | * repeated string address = 5; 189 | * @param index The index of the value to return. 190 | * @return The bytes of the address at the given index. 191 | */ 192 | com.google.protobuf.ByteString 193 | getAddressBytes(int index); 194 | } 195 | /** 196 | * Protobuf type {@code SimplePersonMessageV2} 197 | */ 198 | public static final class SimplePersonMessageV2 extends 199 | com.google.protobuf.GeneratedMessageV3 implements 200 | // @@protoc_insertion_point(message_implements:SimplePersonMessageV2) 201 | SimplePersonMessageV2OrBuilder { 202 | private static final long serialVersionUID = 0L; 203 | // Use SimplePersonMessageV2.newBuilder() to construct. 204 | private SimplePersonMessageV2(com.google.protobuf.GeneratedMessageV3.Builder builder) { 205 | super(builder); 206 | } 207 | private SimplePersonMessageV2() { 208 | name_ = ""; 209 | gender_ = 0; 210 | email_ = ""; 211 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 212 | } 213 | 214 | @java.lang.Override 215 | @SuppressWarnings({"unused"}) 216 | protected java.lang.Object newInstance( 217 | UnusedPrivateParameter unused) { 218 | return new SimplePersonMessageV2(); 219 | } 220 | 221 | @java.lang.Override 222 | public final com.google.protobuf.UnknownFieldSet 223 | getUnknownFields() { 224 | return this.unknownFields; 225 | } 226 | private SimplePersonMessageV2( 227 | com.google.protobuf.CodedInputStream input, 228 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 229 | throws com.google.protobuf.InvalidProtocolBufferException { 230 | this(); 231 | if (extensionRegistry == null) { 232 | throw new java.lang.NullPointerException(); 233 | } 234 | int mutable_bitField0_ = 0; 235 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 236 | com.google.protobuf.UnknownFieldSet.newBuilder(); 237 | try { 238 | boolean done = false; 239 | while (!done) { 240 | int tag = input.readTag(); 241 | switch (tag) { 242 | case 0: 243 | done = true; 244 | break; 245 | case 8: { 246 | 247 | id_ = input.readInt32(); 248 | break; 249 | } 250 | case 18: { 251 | java.lang.String s = input.readStringRequireUtf8(); 252 | 253 | name_ = s; 254 | break; 255 | } 256 | case 24: { 257 | int rawValue = input.readEnum(); 258 | 259 | gender_ = rawValue; 260 | break; 261 | } 262 | case 34: { 263 | java.lang.String s = input.readStringRequireUtf8(); 264 | 265 | email_ = s; 266 | break; 267 | } 268 | case 42: { 269 | java.lang.String s = input.readStringRequireUtf8(); 270 | if (!((mutable_bitField0_ & 0x00000001) != 0)) { 271 | address_ = new com.google.protobuf.LazyStringArrayList(); 272 | mutable_bitField0_ |= 0x00000001; 273 | } 274 | address_.add(s); 275 | break; 276 | } 277 | default: { 278 | if (!parseUnknownField( 279 | input, unknownFields, extensionRegistry, tag)) { 280 | done = true; 281 | } 282 | break; 283 | } 284 | } 285 | } 286 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 287 | throw e.setUnfinishedMessage(this); 288 | } catch (java.io.IOException e) { 289 | throw new com.google.protobuf.InvalidProtocolBufferException( 290 | e).setUnfinishedMessage(this); 291 | } finally { 292 | if (((mutable_bitField0_ & 0x00000001) != 0)) { 293 | address_ = address_.getUnmodifiableView(); 294 | } 295 | this.unknownFields = unknownFields.build(); 296 | makeExtensionsImmutable(); 297 | } 298 | } 299 | public static final com.google.protobuf.Descriptors.Descriptor 300 | getDescriptor() { 301 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.internal_static_SimplePersonMessageV2_descriptor; 302 | } 303 | 304 | @java.lang.Override 305 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 306 | internalGetFieldAccessorTable() { 307 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.internal_static_SimplePersonMessageV2_fieldAccessorTable 308 | .ensureFieldAccessorsInitialized( 309 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.class, com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.Builder.class); 310 | } 311 | 312 | public static final int ID_FIELD_NUMBER = 1; 313 | private int id_; 314 | /** 315 | * int32 id = 1; 316 | * @return The id. 317 | */ 318 | @java.lang.Override 319 | public int getId() { 320 | return id_; 321 | } 322 | 323 | public static final int NAME_FIELD_NUMBER = 2; 324 | private volatile java.lang.Object name_; 325 | /** 326 | * string name = 2; 327 | * @return The name. 328 | */ 329 | @java.lang.Override 330 | public java.lang.String getName() { 331 | java.lang.Object ref = name_; 332 | if (ref instanceof java.lang.String) { 333 | return (java.lang.String) ref; 334 | } else { 335 | com.google.protobuf.ByteString bs = 336 | (com.google.protobuf.ByteString) ref; 337 | java.lang.String s = bs.toStringUtf8(); 338 | name_ = s; 339 | return s; 340 | } 341 | } 342 | /** 343 | * string name = 2; 344 | * @return The bytes for name. 345 | */ 346 | @java.lang.Override 347 | public com.google.protobuf.ByteString 348 | getNameBytes() { 349 | java.lang.Object ref = name_; 350 | if (ref instanceof java.lang.String) { 351 | com.google.protobuf.ByteString b = 352 | com.google.protobuf.ByteString.copyFromUtf8( 353 | (java.lang.String) ref); 354 | name_ = b; 355 | return b; 356 | } else { 357 | return (com.google.protobuf.ByteString) ref; 358 | } 359 | } 360 | 361 | public static final int GENDER_FIELD_NUMBER = 3; 362 | private int gender_; 363 | /** 364 | * .Gender gender = 3; 365 | * @return The enum numeric value on the wire for gender. 366 | */ 367 | @java.lang.Override public int getGenderValue() { 368 | return gender_; 369 | } 370 | /** 371 | * .Gender gender = 3; 372 | * @return The gender. 373 | */ 374 | @java.lang.Override public com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender getGender() { 375 | @SuppressWarnings("deprecation") 376 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender result = com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.valueOf(gender_); 377 | return result == null ? com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.UNRECOGNIZED : result; 378 | } 379 | 380 | public static final int EMAIL_FIELD_NUMBER = 4; 381 | private volatile java.lang.Object email_; 382 | /** 383 | * string email = 4; 384 | * @return The email. 385 | */ 386 | @java.lang.Override 387 | public java.lang.String getEmail() { 388 | java.lang.Object ref = email_; 389 | if (ref instanceof java.lang.String) { 390 | return (java.lang.String) ref; 391 | } else { 392 | com.google.protobuf.ByteString bs = 393 | (com.google.protobuf.ByteString) ref; 394 | java.lang.String s = bs.toStringUtf8(); 395 | email_ = s; 396 | return s; 397 | } 398 | } 399 | /** 400 | * string email = 4; 401 | * @return The bytes for email. 402 | */ 403 | @java.lang.Override 404 | public com.google.protobuf.ByteString 405 | getEmailBytes() { 406 | java.lang.Object ref = email_; 407 | if (ref instanceof java.lang.String) { 408 | com.google.protobuf.ByteString b = 409 | com.google.protobuf.ByteString.copyFromUtf8( 410 | (java.lang.String) ref); 411 | email_ = b; 412 | return b; 413 | } else { 414 | return (com.google.protobuf.ByteString) ref; 415 | } 416 | } 417 | 418 | public static final int ADDRESS_FIELD_NUMBER = 5; 419 | private com.google.protobuf.LazyStringList address_; 420 | /** 421 | * repeated string address = 5; 422 | * @return A list containing the address. 423 | */ 424 | public com.google.protobuf.ProtocolStringList 425 | getAddressList() { 426 | return address_; 427 | } 428 | /** 429 | * repeated string address = 5; 430 | * @return The count of address. 431 | */ 432 | public int getAddressCount() { 433 | return address_.size(); 434 | } 435 | /** 436 | * repeated string address = 5; 437 | * @param index The index of the element to return. 438 | * @return The address at the given index. 439 | */ 440 | public java.lang.String getAddress(int index) { 441 | return address_.get(index); 442 | } 443 | /** 444 | * repeated string address = 5; 445 | * @param index The index of the value to return. 446 | * @return The bytes of the address at the given index. 447 | */ 448 | public com.google.protobuf.ByteString 449 | getAddressBytes(int index) { 450 | return address_.getByteString(index); 451 | } 452 | 453 | private byte memoizedIsInitialized = -1; 454 | @java.lang.Override 455 | public final boolean isInitialized() { 456 | byte isInitialized = memoizedIsInitialized; 457 | if (isInitialized == 1) return true; 458 | if (isInitialized == 0) return false; 459 | 460 | memoizedIsInitialized = 1; 461 | return true; 462 | } 463 | 464 | @java.lang.Override 465 | public void writeTo(com.google.protobuf.CodedOutputStream output) 466 | throws java.io.IOException { 467 | if (id_ != 0) { 468 | output.writeInt32(1, id_); 469 | } 470 | if (!getNameBytes().isEmpty()) { 471 | com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); 472 | } 473 | if (gender_ != com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.MALE.getNumber()) { 474 | output.writeEnum(3, gender_); 475 | } 476 | if (!getEmailBytes().isEmpty()) { 477 | com.google.protobuf.GeneratedMessageV3.writeString(output, 4, email_); 478 | } 479 | for (int i = 0; i < address_.size(); i++) { 480 | com.google.protobuf.GeneratedMessageV3.writeString(output, 5, address_.getRaw(i)); 481 | } 482 | unknownFields.writeTo(output); 483 | } 484 | 485 | @java.lang.Override 486 | public int getSerializedSize() { 487 | int size = memoizedSize; 488 | if (size != -1) return size; 489 | 490 | size = 0; 491 | if (id_ != 0) { 492 | size += com.google.protobuf.CodedOutputStream 493 | .computeInt32Size(1, id_); 494 | } 495 | if (!getNameBytes().isEmpty()) { 496 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); 497 | } 498 | if (gender_ != com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.MALE.getNumber()) { 499 | size += com.google.protobuf.CodedOutputStream 500 | .computeEnumSize(3, gender_); 501 | } 502 | if (!getEmailBytes().isEmpty()) { 503 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, email_); 504 | } 505 | { 506 | int dataSize = 0; 507 | for (int i = 0; i < address_.size(); i++) { 508 | dataSize += computeStringSizeNoTag(address_.getRaw(i)); 509 | } 510 | size += dataSize; 511 | size += 1 * getAddressList().size(); 512 | } 513 | size += unknownFields.getSerializedSize(); 514 | memoizedSize = size; 515 | return size; 516 | } 517 | 518 | @java.lang.Override 519 | public boolean equals(final java.lang.Object obj) { 520 | if (obj == this) { 521 | return true; 522 | } 523 | if (!(obj instanceof com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2)) { 524 | return super.equals(obj); 525 | } 526 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 other = (com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2) obj; 527 | 528 | if (getId() 529 | != other.getId()) return false; 530 | if (!getName() 531 | .equals(other.getName())) return false; 532 | if (gender_ != other.gender_) return false; 533 | if (!getEmail() 534 | .equals(other.getEmail())) return false; 535 | if (!getAddressList() 536 | .equals(other.getAddressList())) return false; 537 | if (!unknownFields.equals(other.unknownFields)) return false; 538 | return true; 539 | } 540 | 541 | @java.lang.Override 542 | public int hashCode() { 543 | if (memoizedHashCode != 0) { 544 | return memoizedHashCode; 545 | } 546 | int hash = 41; 547 | hash = (19 * hash) + getDescriptor().hashCode(); 548 | hash = (37 * hash) + ID_FIELD_NUMBER; 549 | hash = (53 * hash) + getId(); 550 | hash = (37 * hash) + NAME_FIELD_NUMBER; 551 | hash = (53 * hash) + getName().hashCode(); 552 | hash = (37 * hash) + GENDER_FIELD_NUMBER; 553 | hash = (53 * hash) + gender_; 554 | hash = (37 * hash) + EMAIL_FIELD_NUMBER; 555 | hash = (53 * hash) + getEmail().hashCode(); 556 | if (getAddressCount() > 0) { 557 | hash = (37 * hash) + ADDRESS_FIELD_NUMBER; 558 | hash = (53 * hash) + getAddressList().hashCode(); 559 | } 560 | hash = (29 * hash) + unknownFields.hashCode(); 561 | memoizedHashCode = hash; 562 | return hash; 563 | } 564 | 565 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 566 | java.nio.ByteBuffer data) 567 | throws com.google.protobuf.InvalidProtocolBufferException { 568 | return PARSER.parseFrom(data); 569 | } 570 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 571 | java.nio.ByteBuffer data, 572 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 573 | throws com.google.protobuf.InvalidProtocolBufferException { 574 | return PARSER.parseFrom(data, extensionRegistry); 575 | } 576 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 577 | com.google.protobuf.ByteString data) 578 | throws com.google.protobuf.InvalidProtocolBufferException { 579 | return PARSER.parseFrom(data); 580 | } 581 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 582 | com.google.protobuf.ByteString data, 583 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 584 | throws com.google.protobuf.InvalidProtocolBufferException { 585 | return PARSER.parseFrom(data, extensionRegistry); 586 | } 587 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom(byte[] data) 588 | throws com.google.protobuf.InvalidProtocolBufferException { 589 | return PARSER.parseFrom(data); 590 | } 591 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 592 | byte[] data, 593 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 594 | throws com.google.protobuf.InvalidProtocolBufferException { 595 | return PARSER.parseFrom(data, extensionRegistry); 596 | } 597 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom(java.io.InputStream input) 598 | throws java.io.IOException { 599 | return com.google.protobuf.GeneratedMessageV3 600 | .parseWithIOException(PARSER, input); 601 | } 602 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 603 | java.io.InputStream input, 604 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 605 | throws java.io.IOException { 606 | return com.google.protobuf.GeneratedMessageV3 607 | .parseWithIOException(PARSER, input, extensionRegistry); 608 | } 609 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseDelimitedFrom(java.io.InputStream input) 610 | throws java.io.IOException { 611 | return com.google.protobuf.GeneratedMessageV3 612 | .parseDelimitedWithIOException(PARSER, input); 613 | } 614 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseDelimitedFrom( 615 | java.io.InputStream input, 616 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 617 | throws java.io.IOException { 618 | return com.google.protobuf.GeneratedMessageV3 619 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 620 | } 621 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 622 | com.google.protobuf.CodedInputStream input) 623 | throws java.io.IOException { 624 | return com.google.protobuf.GeneratedMessageV3 625 | .parseWithIOException(PARSER, input); 626 | } 627 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parseFrom( 628 | com.google.protobuf.CodedInputStream input, 629 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 630 | throws java.io.IOException { 631 | return com.google.protobuf.GeneratedMessageV3 632 | .parseWithIOException(PARSER, input, extensionRegistry); 633 | } 634 | 635 | @java.lang.Override 636 | public Builder newBuilderForType() { return newBuilder(); } 637 | public static Builder newBuilder() { 638 | return DEFAULT_INSTANCE.toBuilder(); 639 | } 640 | public static Builder newBuilder(com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 prototype) { 641 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 642 | } 643 | @java.lang.Override 644 | public Builder toBuilder() { 645 | return this == DEFAULT_INSTANCE 646 | ? new Builder() : new Builder().mergeFrom(this); 647 | } 648 | 649 | @java.lang.Override 650 | protected Builder newBuilderForType( 651 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 652 | Builder builder = new Builder(parent); 653 | return builder; 654 | } 655 | /** 656 | * Protobuf type {@code SimplePersonMessageV2} 657 | */ 658 | public static final class Builder extends 659 | com.google.protobuf.GeneratedMessageV3.Builder implements 660 | // @@protoc_insertion_point(builder_implements:SimplePersonMessageV2) 661 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2OrBuilder { 662 | public static final com.google.protobuf.Descriptors.Descriptor 663 | getDescriptor() { 664 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.internal_static_SimplePersonMessageV2_descriptor; 665 | } 666 | 667 | @java.lang.Override 668 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 669 | internalGetFieldAccessorTable() { 670 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.internal_static_SimplePersonMessageV2_fieldAccessorTable 671 | .ensureFieldAccessorsInitialized( 672 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.class, com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.Builder.class); 673 | } 674 | 675 | // Construct using com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.newBuilder() 676 | private Builder() { 677 | maybeForceBuilderInitialization(); 678 | } 679 | 680 | private Builder( 681 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 682 | super(parent); 683 | maybeForceBuilderInitialization(); 684 | } 685 | private void maybeForceBuilderInitialization() { 686 | if (com.google.protobuf.GeneratedMessageV3 687 | .alwaysUseFieldBuilders) { 688 | } 689 | } 690 | @java.lang.Override 691 | public Builder clear() { 692 | super.clear(); 693 | id_ = 0; 694 | 695 | name_ = ""; 696 | 697 | gender_ = 0; 698 | 699 | email_ = ""; 700 | 701 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 702 | bitField0_ = (bitField0_ & ~0x00000001); 703 | return this; 704 | } 705 | 706 | @java.lang.Override 707 | public com.google.protobuf.Descriptors.Descriptor 708 | getDescriptorForType() { 709 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.internal_static_SimplePersonMessageV2_descriptor; 710 | } 711 | 712 | @java.lang.Override 713 | public com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 getDefaultInstanceForType() { 714 | return com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.getDefaultInstance(); 715 | } 716 | 717 | @java.lang.Override 718 | public com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 build() { 719 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 result = buildPartial(); 720 | if (!result.isInitialized()) { 721 | throw newUninitializedMessageException(result); 722 | } 723 | return result; 724 | } 725 | 726 | @java.lang.Override 727 | public com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 buildPartial() { 728 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 result = new com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2(this); 729 | int from_bitField0_ = bitField0_; 730 | result.id_ = id_; 731 | result.name_ = name_; 732 | result.gender_ = gender_; 733 | result.email_ = email_; 734 | if (((bitField0_ & 0x00000001) != 0)) { 735 | address_ = address_.getUnmodifiableView(); 736 | bitField0_ = (bitField0_ & ~0x00000001); 737 | } 738 | result.address_ = address_; 739 | onBuilt(); 740 | return result; 741 | } 742 | 743 | @java.lang.Override 744 | public Builder clone() { 745 | return super.clone(); 746 | } 747 | @java.lang.Override 748 | public Builder setField( 749 | com.google.protobuf.Descriptors.FieldDescriptor field, 750 | java.lang.Object value) { 751 | return super.setField(field, value); 752 | } 753 | @java.lang.Override 754 | public Builder clearField( 755 | com.google.protobuf.Descriptors.FieldDescriptor field) { 756 | return super.clearField(field); 757 | } 758 | @java.lang.Override 759 | public Builder clearOneof( 760 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 761 | return super.clearOneof(oneof); 762 | } 763 | @java.lang.Override 764 | public Builder setRepeatedField( 765 | com.google.protobuf.Descriptors.FieldDescriptor field, 766 | int index, java.lang.Object value) { 767 | return super.setRepeatedField(field, index, value); 768 | } 769 | @java.lang.Override 770 | public Builder addRepeatedField( 771 | com.google.protobuf.Descriptors.FieldDescriptor field, 772 | java.lang.Object value) { 773 | return super.addRepeatedField(field, value); 774 | } 775 | @java.lang.Override 776 | public Builder mergeFrom(com.google.protobuf.Message other) { 777 | if (other instanceof com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2) { 778 | return mergeFrom((com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2)other); 779 | } else { 780 | super.mergeFrom(other); 781 | return this; 782 | } 783 | } 784 | 785 | public Builder mergeFrom(com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 other) { 786 | if (other == com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2.getDefaultInstance()) return this; 787 | if (other.getId() != 0) { 788 | setId(other.getId()); 789 | } 790 | if (!other.getName().isEmpty()) { 791 | name_ = other.name_; 792 | onChanged(); 793 | } 794 | if (other.gender_ != 0) { 795 | setGenderValue(other.getGenderValue()); 796 | } 797 | if (!other.getEmail().isEmpty()) { 798 | email_ = other.email_; 799 | onChanged(); 800 | } 801 | if (!other.address_.isEmpty()) { 802 | if (address_.isEmpty()) { 803 | address_ = other.address_; 804 | bitField0_ = (bitField0_ & ~0x00000001); 805 | } else { 806 | ensureAddressIsMutable(); 807 | address_.addAll(other.address_); 808 | } 809 | onChanged(); 810 | } 811 | this.mergeUnknownFields(other.unknownFields); 812 | onChanged(); 813 | return this; 814 | } 815 | 816 | @java.lang.Override 817 | public final boolean isInitialized() { 818 | return true; 819 | } 820 | 821 | @java.lang.Override 822 | public Builder mergeFrom( 823 | com.google.protobuf.CodedInputStream input, 824 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 825 | throws java.io.IOException { 826 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 parsedMessage = null; 827 | try { 828 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 829 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 830 | parsedMessage = (com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2) e.getUnfinishedMessage(); 831 | throw e.unwrapIOException(); 832 | } finally { 833 | if (parsedMessage != null) { 834 | mergeFrom(parsedMessage); 835 | } 836 | } 837 | return this; 838 | } 839 | private int bitField0_; 840 | 841 | private int id_ ; 842 | /** 843 | * int32 id = 1; 844 | * @return The id. 845 | */ 846 | @java.lang.Override 847 | public int getId() { 848 | return id_; 849 | } 850 | /** 851 | * int32 id = 1; 852 | * @param value The id to set. 853 | * @return This builder for chaining. 854 | */ 855 | public Builder setId(int value) { 856 | 857 | id_ = value; 858 | onChanged(); 859 | return this; 860 | } 861 | /** 862 | * int32 id = 1; 863 | * @return This builder for chaining. 864 | */ 865 | public Builder clearId() { 866 | 867 | id_ = 0; 868 | onChanged(); 869 | return this; 870 | } 871 | 872 | private java.lang.Object name_ = ""; 873 | /** 874 | * string name = 2; 875 | * @return The name. 876 | */ 877 | public java.lang.String getName() { 878 | java.lang.Object ref = name_; 879 | if (!(ref instanceof java.lang.String)) { 880 | com.google.protobuf.ByteString bs = 881 | (com.google.protobuf.ByteString) ref; 882 | java.lang.String s = bs.toStringUtf8(); 883 | name_ = s; 884 | return s; 885 | } else { 886 | return (java.lang.String) ref; 887 | } 888 | } 889 | /** 890 | * string name = 2; 891 | * @return The bytes for name. 892 | */ 893 | public com.google.protobuf.ByteString 894 | getNameBytes() { 895 | java.lang.Object ref = name_; 896 | if (ref instanceof String) { 897 | com.google.protobuf.ByteString b = 898 | com.google.protobuf.ByteString.copyFromUtf8( 899 | (java.lang.String) ref); 900 | name_ = b; 901 | return b; 902 | } else { 903 | return (com.google.protobuf.ByteString) ref; 904 | } 905 | } 906 | /** 907 | * string name = 2; 908 | * @param value The name to set. 909 | * @return This builder for chaining. 910 | */ 911 | public Builder setName( 912 | java.lang.String value) { 913 | if (value == null) { 914 | throw new NullPointerException(); 915 | } 916 | 917 | name_ = value; 918 | onChanged(); 919 | return this; 920 | } 921 | /** 922 | * string name = 2; 923 | * @return This builder for chaining. 924 | */ 925 | public Builder clearName() { 926 | 927 | name_ = getDefaultInstance().getName(); 928 | onChanged(); 929 | return this; 930 | } 931 | /** 932 | * string name = 2; 933 | * @param value The bytes for name to set. 934 | * @return This builder for chaining. 935 | */ 936 | public Builder setNameBytes( 937 | com.google.protobuf.ByteString value) { 938 | if (value == null) { 939 | throw new NullPointerException(); 940 | } 941 | checkByteStringIsUtf8(value); 942 | 943 | name_ = value; 944 | onChanged(); 945 | return this; 946 | } 947 | 948 | private int gender_ = 0; 949 | /** 950 | * .Gender gender = 3; 951 | * @return The enum numeric value on the wire for gender. 952 | */ 953 | @java.lang.Override public int getGenderValue() { 954 | return gender_; 955 | } 956 | /** 957 | * .Gender gender = 3; 958 | * @param value The enum numeric value on the wire for gender to set. 959 | * @return This builder for chaining. 960 | */ 961 | public Builder setGenderValue(int value) { 962 | 963 | gender_ = value; 964 | onChanged(); 965 | return this; 966 | } 967 | /** 968 | * .Gender gender = 3; 969 | * @return The gender. 970 | */ 971 | @java.lang.Override 972 | public com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender getGender() { 973 | @SuppressWarnings("deprecation") 974 | com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender result = com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.valueOf(gender_); 975 | return result == null ? com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender.UNRECOGNIZED : result; 976 | } 977 | /** 978 | * .Gender gender = 3; 979 | * @param value The gender to set. 980 | * @return This builder for chaining. 981 | */ 982 | public Builder setGender(com.fengfshao.dynamicproto.pb3.SimplePersonV2.Gender value) { 983 | if (value == null) { 984 | throw new NullPointerException(); 985 | } 986 | 987 | gender_ = value.getNumber(); 988 | onChanged(); 989 | return this; 990 | } 991 | /** 992 | * .Gender gender = 3; 993 | * @return This builder for chaining. 994 | */ 995 | public Builder clearGender() { 996 | 997 | gender_ = 0; 998 | onChanged(); 999 | return this; 1000 | } 1001 | 1002 | private java.lang.Object email_ = ""; 1003 | /** 1004 | * string email = 4; 1005 | * @return The email. 1006 | */ 1007 | public java.lang.String getEmail() { 1008 | java.lang.Object ref = email_; 1009 | if (!(ref instanceof java.lang.String)) { 1010 | com.google.protobuf.ByteString bs = 1011 | (com.google.protobuf.ByteString) ref; 1012 | java.lang.String s = bs.toStringUtf8(); 1013 | email_ = s; 1014 | return s; 1015 | } else { 1016 | return (java.lang.String) ref; 1017 | } 1018 | } 1019 | /** 1020 | * string email = 4; 1021 | * @return The bytes for email. 1022 | */ 1023 | public com.google.protobuf.ByteString 1024 | getEmailBytes() { 1025 | java.lang.Object ref = email_; 1026 | if (ref instanceof String) { 1027 | com.google.protobuf.ByteString b = 1028 | com.google.protobuf.ByteString.copyFromUtf8( 1029 | (java.lang.String) ref); 1030 | email_ = b; 1031 | return b; 1032 | } else { 1033 | return (com.google.protobuf.ByteString) ref; 1034 | } 1035 | } 1036 | /** 1037 | * string email = 4; 1038 | * @param value The email to set. 1039 | * @return This builder for chaining. 1040 | */ 1041 | public Builder setEmail( 1042 | java.lang.String value) { 1043 | if (value == null) { 1044 | throw new NullPointerException(); 1045 | } 1046 | 1047 | email_ = value; 1048 | onChanged(); 1049 | return this; 1050 | } 1051 | /** 1052 | * string email = 4; 1053 | * @return This builder for chaining. 1054 | */ 1055 | public Builder clearEmail() { 1056 | 1057 | email_ = getDefaultInstance().getEmail(); 1058 | onChanged(); 1059 | return this; 1060 | } 1061 | /** 1062 | * string email = 4; 1063 | * @param value The bytes for email to set. 1064 | * @return This builder for chaining. 1065 | */ 1066 | public Builder setEmailBytes( 1067 | com.google.protobuf.ByteString value) { 1068 | if (value == null) { 1069 | throw new NullPointerException(); 1070 | } 1071 | checkByteStringIsUtf8(value); 1072 | 1073 | email_ = value; 1074 | onChanged(); 1075 | return this; 1076 | } 1077 | 1078 | private com.google.protobuf.LazyStringList address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 1079 | private void ensureAddressIsMutable() { 1080 | if (!((bitField0_ & 0x00000001) != 0)) { 1081 | address_ = new com.google.protobuf.LazyStringArrayList(address_); 1082 | bitField0_ |= 0x00000001; 1083 | } 1084 | } 1085 | /** 1086 | * repeated string address = 5; 1087 | * @return A list containing the address. 1088 | */ 1089 | public com.google.protobuf.ProtocolStringList 1090 | getAddressList() { 1091 | return address_.getUnmodifiableView(); 1092 | } 1093 | /** 1094 | * repeated string address = 5; 1095 | * @return The count of address. 1096 | */ 1097 | public int getAddressCount() { 1098 | return address_.size(); 1099 | } 1100 | /** 1101 | * repeated string address = 5; 1102 | * @param index The index of the element to return. 1103 | * @return The address at the given index. 1104 | */ 1105 | public java.lang.String getAddress(int index) { 1106 | return address_.get(index); 1107 | } 1108 | /** 1109 | * repeated string address = 5; 1110 | * @param index The index of the value to return. 1111 | * @return The bytes of the address at the given index. 1112 | */ 1113 | public com.google.protobuf.ByteString 1114 | getAddressBytes(int index) { 1115 | return address_.getByteString(index); 1116 | } 1117 | /** 1118 | * repeated string address = 5; 1119 | * @param index The index to set the value at. 1120 | * @param value The address to set. 1121 | * @return This builder for chaining. 1122 | */ 1123 | public Builder setAddress( 1124 | int index, java.lang.String value) { 1125 | if (value == null) { 1126 | throw new NullPointerException(); 1127 | } 1128 | ensureAddressIsMutable(); 1129 | address_.set(index, value); 1130 | onChanged(); 1131 | return this; 1132 | } 1133 | /** 1134 | * repeated string address = 5; 1135 | * @param value The address to add. 1136 | * @return This builder for chaining. 1137 | */ 1138 | public Builder addAddress( 1139 | java.lang.String value) { 1140 | if (value == null) { 1141 | throw new NullPointerException(); 1142 | } 1143 | ensureAddressIsMutable(); 1144 | address_.add(value); 1145 | onChanged(); 1146 | return this; 1147 | } 1148 | /** 1149 | * repeated string address = 5; 1150 | * @param values The address to add. 1151 | * @return This builder for chaining. 1152 | */ 1153 | public Builder addAllAddress( 1154 | java.lang.Iterable values) { 1155 | ensureAddressIsMutable(); 1156 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 1157 | values, address_); 1158 | onChanged(); 1159 | return this; 1160 | } 1161 | /** 1162 | * repeated string address = 5; 1163 | * @return This builder for chaining. 1164 | */ 1165 | public Builder clearAddress() { 1166 | address_ = com.google.protobuf.LazyStringArrayList.EMPTY; 1167 | bitField0_ = (bitField0_ & ~0x00000001); 1168 | onChanged(); 1169 | return this; 1170 | } 1171 | /** 1172 | * repeated string address = 5; 1173 | * @param value The bytes of the address to add. 1174 | * @return This builder for chaining. 1175 | */ 1176 | public Builder addAddressBytes( 1177 | com.google.protobuf.ByteString value) { 1178 | if (value == null) { 1179 | throw new NullPointerException(); 1180 | } 1181 | checkByteStringIsUtf8(value); 1182 | ensureAddressIsMutable(); 1183 | address_.add(value); 1184 | onChanged(); 1185 | return this; 1186 | } 1187 | @java.lang.Override 1188 | public final Builder setUnknownFields( 1189 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1190 | return super.setUnknownFields(unknownFields); 1191 | } 1192 | 1193 | @java.lang.Override 1194 | public final Builder mergeUnknownFields( 1195 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1196 | return super.mergeUnknownFields(unknownFields); 1197 | } 1198 | 1199 | 1200 | // @@protoc_insertion_point(builder_scope:SimplePersonMessageV2) 1201 | } 1202 | 1203 | // @@protoc_insertion_point(class_scope:SimplePersonMessageV2) 1204 | private static final com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 DEFAULT_INSTANCE; 1205 | static { 1206 | DEFAULT_INSTANCE = new com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2(); 1207 | } 1208 | 1209 | public static com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 getDefaultInstance() { 1210 | return DEFAULT_INSTANCE; 1211 | } 1212 | 1213 | private static final com.google.protobuf.Parser 1214 | PARSER = new com.google.protobuf.AbstractParser() { 1215 | @java.lang.Override 1216 | public SimplePersonMessageV2 parsePartialFrom( 1217 | com.google.protobuf.CodedInputStream input, 1218 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1219 | throws com.google.protobuf.InvalidProtocolBufferException { 1220 | return new SimplePersonMessageV2(input, extensionRegistry); 1221 | } 1222 | }; 1223 | 1224 | public static com.google.protobuf.Parser parser() { 1225 | return PARSER; 1226 | } 1227 | 1228 | @java.lang.Override 1229 | public com.google.protobuf.Parser getParserForType() { 1230 | return PARSER; 1231 | } 1232 | 1233 | @java.lang.Override 1234 | public com.fengfshao.dynamicproto.pb3.SimplePersonV2.SimplePersonMessageV2 getDefaultInstanceForType() { 1235 | return DEFAULT_INSTANCE; 1236 | } 1237 | 1238 | } 1239 | 1240 | private static final com.google.protobuf.Descriptors.Descriptor 1241 | internal_static_SimplePersonMessageV2_descriptor; 1242 | private static final 1243 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1244 | internal_static_SimplePersonMessageV2_fieldAccessorTable; 1245 | 1246 | public static com.google.protobuf.Descriptors.FileDescriptor 1247 | getDescriptor() { 1248 | return descriptor; 1249 | } 1250 | private static com.google.protobuf.Descriptors.FileDescriptor 1251 | descriptor; 1252 | static { 1253 | java.lang.String[] descriptorData = { 1254 | "\n\025simple_personv2.proto\"j\n\025SimplePersonM" + 1255 | "essageV2\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030\002 \001(\t\022\027\n\006ge" + 1256 | "nder\030\003 \001(\0162\007.Gender\022\r\n\005email\030\004 \001(\t\022\017\n\007ad" + 1257 | "dress\030\005 \003(\t*\036\n\006Gender\022\010\n\004MALE\020\000\022\n\n\006FEMAL" + 1258 | "E\020\001B0\n\036com.fengfshao.dynamicproto.pb3B\016S" + 1259 | "implePersonV2b\006proto3" 1260 | }; 1261 | descriptor = com.google.protobuf.Descriptors.FileDescriptor 1262 | .internalBuildGeneratedFileFrom(descriptorData, 1263 | new com.google.protobuf.Descriptors.FileDescriptor[] { 1264 | }); 1265 | internal_static_SimplePersonMessageV2_descriptor = 1266 | getDescriptor().getMessageTypes().get(0); 1267 | internal_static_SimplePersonMessageV2_fieldAccessorTable = new 1268 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1269 | internal_static_SimplePersonMessageV2_descriptor, 1270 | new java.lang.String[] { "Id", "Name", "Gender", "Email", "Address", }); 1271 | } 1272 | 1273 | // @@protoc_insertion_point(outer_class_scope) 1274 | } 1275 | -------------------------------------------------------------------------------- /src/test/resources/multiple_person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.fengfshao.dynamicproto.pb3"; 4 | option java_outer_classname = "MultiplePerson"; 5 | 6 | message MultiplePersonMessage { 7 | int32 id = 1; 8 | string name = 2; 9 | Gender gender = 3; 10 | string email = 4; 11 | repeated string address = 5; 12 | repeated Dog pets = 6; 13 | } 14 | 15 | enum Gender{ 16 | MALE = 0; 17 | FEMALE = 1; 18 | } 19 | 20 | message Dog { 21 | string name = 1; 22 | int32 age = 2; 23 | } -------------------------------------------------------------------------------- /src/test/resources/nested_person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.fengfshao.dynamicproto.pb3"; 4 | option java_outer_classname = "NestedPerson"; 5 | 6 | message NestedPersonMessage { 7 | int32 id = 1; 8 | string name = 2; 9 | Gender gender = 3; 10 | string email = 4; 11 | repeated string address = 5; 12 | repeated Dog pets = 6; 13 | 14 | enum Gender{ 15 | MALE = 0; 16 | FEMALE = 1; 17 | } 18 | 19 | message Dog { 20 | string name = 1; 21 | int32 age = 2; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/simple_person.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.fengfshao.dynamicproto.pb3"; 4 | option java_outer_classname = "SimplePerson"; 5 | 6 | message SimplePersonMessage { 7 | int32 id = 1; 8 | string name = 2; 9 | string email = 3; 10 | repeated string address = 4; 11 | } -------------------------------------------------------------------------------- /src/test/resources/simple_personv2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_package = "com.fengfshao.dynamicproto.pb3"; 4 | option java_outer_classname = "SimplePersonV2"; 5 | 6 | message SimplePersonMessageV2 { 7 | int32 id = 1; 8 | string name = 2; 9 | Gender gender = 3; 10 | string email = 4; 11 | repeated string address = 5; 12 | } 13 | 14 | enum Gender{ 15 | MALE = 0; 16 | FEMALE = 1; 17 | } --------------------------------------------------------------------------------