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.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;
 }
 @ImmutablePreBuild
 private static void preBuild(Builder builder) {
   if (builder.label == null && builder.template != null) {
     builder.label = builder.template.getTenor().toString();
   }
 }