# File lib/rbrainz/model/mbid.rb, line 104
      def initialize(str, entity_type=nil)
        str = str.to_s if str.respond_to? :to_s
        unless is_valid_entity_type_or_nil(entity_type)
          raise UnknownEntityError, entity_type
        end
        entity_type = Utils.entity_type_to_symbol(entity_type)
        
        if str =~ ENTITY_URI_REGEXP
          @entity = Utils.entity_type_to_symbol($1)
          @uuid = $2.downcase
          unless entity_type.nil? || @entity == entity_type
            raise EntityTypeNotMatchingError, "#{@entity}, #{entity_type}"
          end
        elsif str =~ UUID_REGEXP
          unless entity_type
            raise UnknownEntityError, "nil is not a valid entity type"
          end
          @entity = entity_type
          @uuid = str.downcase
        else
          raise InvalidMBIDError, str
        end
      end