def __init__(self,
                 message_type,
                 number,
                 required=False,
                 repeated=False,
                 variant=None):
        """Constructor.

        Args:
          message_type: Message type for field.  Must be subclass of Message.
          number: Number of field.  Must be unique per message class.
          required: Whether or not field is required.  Mutually exclusive to
            'repeated'.
          repeated: Whether or not field is repeated.  Mutually exclusive to
            'required'.
          variant: Wire-format variant hint.

        Raises:
          FieldDefinitionError when invalid message_type is provided.
        """
        valid_type = (isinstance(message_type, six.string_types) or
                      (message_type is not Message and
                       isinstance(message_type, type) and
                       issubclass(message_type, Message)))

        if not valid_type:
            raise FieldDefinitionError(
                'Invalid message class: %s' % message_type)

        if isinstance(message_type, six.string_types):
            self.__type_name = message_type
            self.__type = None
        else:
            self.__type = message_type

        super(MessageField, self).__init__(number,
                                           required=required,
                                           repeated=repeated,
                                           variant=variant)