Example #1
0
 @Override
 public FieldDescriptorProto decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.name(ProtoAdapter.STRING.decode(reader));
         break;
       case 9:
         builder.doc(ProtoAdapter.STRING.decode(reader));
         break;
       case 3:
         builder.number(ProtoAdapter.INT32.decode(reader));
         break;
       case 4:
         {
           try {
             builder.label(Label.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       case 5:
         {
           try {
             builder.type(Type.ADAPTER.decode(reader));
           } catch (ProtoAdapter.EnumConstantNotFoundException e) {
             builder.addUnknownField(tag, FieldEncoding.VARINT, (long) e.value);
           }
           break;
         }
       case 6:
         builder.type_name(ProtoAdapter.STRING.decode(reader));
         break;
       case 2:
         builder.extendee(ProtoAdapter.STRING.decode(reader));
         break;
       case 7:
         builder.default_value(ProtoAdapter.STRING.decode(reader));
         break;
       case 8:
         builder.options(FieldOptions.ADAPTER.decode(reader));
         break;
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }
Example #2
0
 @Override
 public Builder newBuilder() {
   Builder builder = new Builder();
   builder.name = name;
   builder.doc = doc;
   builder.field = copyOf(field);
   builder.extension = copyOf(extension);
   builder.nested_type = copyOf(nested_type);
   builder.enum_type = copyOf(enum_type);
   builder.extension_range = copyOf(extension_range);
   builder.options = options;
   builder.addUnknownFields(unknownFields());
   return builder;
 }
Example #3
0
 @Override
 public Builder newBuilder() {
   Builder builder = new Builder();
   builder.name = name;
   builder.doc = doc;
   builder.number = number;
   builder.label = label;
   builder.type = type;
   builder.type_name = type_name;
   builder.extendee = extendee;
   builder.default_value = default_value;
   builder.options = options;
   builder.addUnknownFields(unknownFields());
   return builder;
 }
Example #4
0
 @Override
 public DescriptorProto decode(ProtoReader reader) throws IOException {
   Builder builder = new Builder();
   long token = reader.beginMessage();
   for (int tag; (tag = reader.nextTag()) != -1; ) {
     switch (tag) {
       case 1:
         builder.name(ProtoAdapter.STRING.decode(reader));
         break;
       case 8:
         builder.doc(ProtoAdapter.STRING.decode(reader));
         break;
       case 2:
         builder.field.add(FieldDescriptorProto.ADAPTER.decode(reader));
         break;
       case 6:
         builder.extension.add(FieldDescriptorProto.ADAPTER.decode(reader));
         break;
       case 3:
         builder.nested_type.add(DescriptorProto.ADAPTER.decode(reader));
         break;
       case 4:
         builder.enum_type.add(EnumDescriptorProto.ADAPTER.decode(reader));
         break;
       case 5:
         builder.extension_range.add(ExtensionRange.ADAPTER.decode(reader));
         break;
       case 7:
         builder.options(MessageOptions.ADAPTER.decode(reader));
         break;
       default:
         {
           FieldEncoding fieldEncoding = reader.peekFieldEncoding();
           Object value = fieldEncoding.rawProtoAdapter().decode(reader);
           builder.addUnknownField(tag, fieldEncoding, value);
         }
     }
   }
   reader.endMessage(token);
   return builder.build();
 }