code: public static MediaType valueOf(String type) throws IllegalArgumentException {
          if (type == null || type.trim().isEmpty() || type.startsWith(SUBTYPE_SEPARATOR) || type.endsWith(SUBTYPE_SEPARATOR)) {
              throw new IllegalArgumentException("Invalid mime type '" + type + "'");
          }
          String[] splitType = type.split(SUBTYPE_SEPARATOR);
          if (splitType.length == 2) {
              nonEmpty(type, splitType[0]);
              nonEmpty(type, splitType[1]);
              Map<String, String> parameters = new HashMap<>();
              String subType = splitType[1];
              if (splitType[1].contains(PARAMETERS_SEPARATOR)) {
                  String[] subTypeWithparameter = splitType[1].split(PARAMETERS_SEPARATOR);
                  String paramString = subTypeWithparameter[1].trim();
                  subType = subTypeWithparameter[0];
                  parameters = parseParameters(paramString);
              }
              return new MediaType(splitType[0].trim(), subType.trim(), parameters);
          }
          if (!type.contains(SUBTYPE_SEPARATOR)) {
              String mimeType = mimeMappings.getMimeType(type);
              if (mimeType != null) {
                  return valueOf(mimeType);
              }
          }
          throw new IllegalArgumentException("Invalid mime type '" + type + "'");
      }
docs: Creates a new instance of MediaType by parsing the supplied string.
  
  @param type the media type string
  @return the newly created MediaType
  @throws IllegalArgumentException if the supplied string cannot be parsed
  or is null