Class MediaType

java.lang.Object
org.junit.jupiter.api.MediaType
Direct Known Subclasses:
MediaType

@API(status=MAINTAINED, since="5.14") public sealed class MediaType extends Object permits MediaType
Represents a media type as defined by RFC 2045.

WARNING: This type should not be extended by third parties.

Since:
5.14
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_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.
  • Constructor Details

  • 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 or blank
      Returns:
      the parsed 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 or blank
      subtype - the subtype; never null or blank
      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 or blank
      subtype - the subtype; never null or blank
      charset - the charset; never null
      Returns:
      the media type
    • toString

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

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

      public final int hashCode()
      Overrides:
      hashCode in class Object