@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();
 }
 @Override
 public void encode(ProtoWriter writer, FieldDescriptorProto value) throws IOException {
   if (value.name != null) ProtoAdapter.STRING.encodeTagged(writer, 1, value.name);
   if (value.doc != null) ProtoAdapter.STRING.encodeTagged(writer, 9, value.doc);
   if (value.number != null) ProtoAdapter.INT32.encodeTagged(writer, 3, value.number);
   if (value.label != null) Label.ADAPTER.encodeTagged(writer, 4, value.label);
   if (value.type != null) Type.ADAPTER.encodeTagged(writer, 5, value.type);
   if (value.type_name != null) ProtoAdapter.STRING.encodeTagged(writer, 6, value.type_name);
   if (value.extendee != null) ProtoAdapter.STRING.encodeTagged(writer, 2, value.extendee);
   if (value.default_value != null)
     ProtoAdapter.STRING.encodeTagged(writer, 7, value.default_value);
   if (value.options != null) FieldOptions.ADAPTER.encodeTagged(writer, 8, value.options);
   writer.writeBytes(value.unknownFields());
 }
 @Override
 public int encodedSize(FieldDescriptorProto value) {
   return (value.name != null ? ProtoAdapter.STRING.encodedSize(1, value.name) : 0)
       + (value.doc != null ? ProtoAdapter.STRING.encodedSize(9, value.doc) : 0)
       + (value.number != null ? ProtoAdapter.INT32.encodedSize(3, value.number) : 0)
       + (value.label != null ? Label.ADAPTER.encodedSize(4, value.label) : 0)
       + (value.type != null ? Type.ADAPTER.encodedSize(5, value.type) : 0)
       + (value.type_name != null ? ProtoAdapter.STRING.encodedSize(6, value.type_name) : 0)
       + (value.extendee != null ? ProtoAdapter.STRING.encodedSize(2, value.extendee) : 0)
       + (value.default_value != null
           ? ProtoAdapter.STRING.encodedSize(7, value.default_value)
           : 0)
       + (value.options != null ? FieldOptions.ADAPTER.encodedSize(8, value.options) : 0)
       + value.unknownFields().size();
 }