Class MediaType

java.lang.Object
org.junit.jupiter.api.extension.MediaType

@API(status=EXPERIMENTAL, since="5.12") public class MediaType extends Object
Represents a media type as defined by RFC 2045.
Since:
5.12
See Also:
  • Field Details

    • TEXT_PLAIN

      public static final MediaType TEXT_PLAIN
      The text/plain media type.
    • TEXT_PLAIN_UTF_8

      public static final MediaType TEXT_PLAIN_UTF_8
      The text/plain; charset=UTF-8 media type.
    • APPLICATION_JSON

      public static final MediaType APPLICATION_JSON
      The application/json media type.
    • APPLICATION_JSON_UTF_8

      public static final MediaType APPLICATION_JSON_UTF_8
      The application/json; charset=UTF-8 media type.
    • APPLICATION_OCTET_STREAM

      public static final MediaType APPLICATION_OCTET_STREAM
      The application/octet-stream media type.
    • IMAGE_JPEG

      public static final MediaType IMAGE_JPEG
      The image/jpeg media type.
    • IMAGE_PNG

      public static final MediaType IMAGE_PNG
      The image/png media type.
  • Method Details

    • parse

      public static MediaType parse(String value)
      Parse the given media type value.

      Must be valid according to RFC 2045.

      Parameters:
      value - the media type value to parse; never null
      Returns:
      the parsed media type
      Throws:
      PreconditionViolationException - if the value is not a valid media type
    • create

      public static MediaType create(String type, String subtype)
      Create a media type with the given type and subtype.
      Parameters:
      type - the type; never null
      subtype - the subtype; never null
      Returns:
      the media type
    • create

      public static MediaType create(String type, String subtype, Charset charset)
      Create a media type with the given type, subtype, and charset.
      Parameters:
      type - the type; never null
      subtype - the subtype; never null
      charset - the charset; never null
      Returns:
      the media type
    • toString

      public String toString()
      Returns string representation of this media type.
      Overrides:
      toString in class Object
      Returns:
      string representation of this media type
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object