docs: private static final ResultParser findParser(String mediaType, ResultType expectedType) {
      ResponseFormat format = null;
      
      // Prefer MIME type when choosing result format.
      if (mediaType != null) {
        mediaType = stripParams(mediaType);
        format = mimeFormats.get(mediaType);
        if (format == null) {
          logger.warn("Unrecognized media type ({}) in SPARQL server response", mediaType);
        } else {
          logger.debug("Using result format {} for media type {}", format, mediaType);
        }
      }
      
      // If MIME type was absent or unrecognized, choose default based on expected result type.
      if (format == null) {
        logger.debug("Unable to determine result format from media type");
        if (expectedType != null) {
          format = defaultTypeFormats.get(expectedType);
          logger.debug("Using default format {} for expected result type {}", format, expectedType);
        } else {
          format = DEFAULT_FORMAT;
          logger.debug("No expected type provided; using default format {}", format);
        }
      }
      
      assert format != null:"Could not determine result format";
      
      // Validate that the chosen format can produce the expected result type.
      if (expectedType != null && !format.resultTypes.contains(expectedType)) {
        throw new SparqlException("Result format " + format + " does not support expected result type " + expectedType);
      }
      
      return format.parser;
    }