code: public static <T> T visitField(FieldDescriptor fieldDescriptor, FieldVisitor<T> visitor) {
      // NOTE: map fields are technically repeated, so check isMap first.
      if (fieldDescriptor.isMapField()) {
        List<FieldDescriptor> mapFields = fieldDescriptor.getMessageType().getFields();
        checkState(mapFields.size() == 2, "proto representation of map fields changed");
        FieldDescriptor keyField = mapFields.get(0);
        FieldDescriptor valueField = mapFields.get(1);
        return visitor.visitMap(
            fieldDescriptor, getScalarType(keyField, visitor), getScalarType(valueField, visitor));
      } else if (fieldDescriptor.isRepeated()) {
        return visitor.visitRepeated(getScalarType(fieldDescriptor, visitor));
      } else {
        return getScalarType(fieldDescriptor, visitor);
      }
    }
docs: Applies the visitor to the given field.