MediaType { public MediaType withCharset(final String charset) { return new MediaType(this.type, this.subtype, charset, createParametersMap(this.parameters)); } MediaType(final String type, final String subtype, final Map<String, String> parameters);  MediaType(final String type, final String subtype);  MediaType(final String type, final String subtype, final String charset);  MediaType(); private  MediaType(final String type, final String subtype, final String charset, Map<String, String> parameterMap); static MediaType valueOf(final String type); String getType(); boolean isWildcardType(); String getSubtype(); boolean isWildcardSubtype(); Map<String, String> getParameters(); MediaType withCharset(final String charset); boolean isCompatible(final MediaType other); @SuppressWarnings("UnnecessaryJavaDocLink") @Override boolean equals(final Object obj); @SuppressWarnings("UnnecessaryJavaDocLink") @Override int hashCode(); @Override String toString(); static final String CHARSET_PARAMETER; static final String MEDIA_TYPE_WILDCARD; final static String WILDCARD; final static MediaType WILDCARD_TYPE; final static String APPLICATION_XML; final static MediaType APPLICATION_XML_TYPE; final static String APPLICATION_ATOM_XML; final static MediaType APPLICATION_ATOM_XML_TYPE; final static String APPLICATION_XHTML_XML; final static MediaType APPLICATION_XHTML_XML_TYPE; final static String APPLICATION_SVG_XML; final static MediaType APPLICATION_SVG_XML_TYPE; final static String APPLICATION_JSON; final static MediaType APPLICATION_JSON_TYPE; final static String APPLICATION_FORM_URLENCODED; final static MediaType APPLICATION_FORM_URLENCODED_TYPE; final static String MULTIPART_FORM_DATA; final static MediaType MULTIPART_FORM_DATA_TYPE; final static String APPLICATION_OCTET_STREAM; final static MediaType APPLICATION_OCTET_STREAM_TYPE; final static String TEXT_PLAIN; final static MediaType TEXT_PLAIN_TYPE; final static String TEXT_XML; final static MediaType TEXT_XML_TYPE; final static String TEXT_HTML; final static MediaType TEXT_HTML_TYPE; static final String SERVER_SENT_EVENTS; static final MediaType SERVER_SENT_EVENTS_TYPE; static final String APPLICATION_JSON_PATCH_JSON; static final MediaType APPLICATION_JSON_PATCH_JSON_TYPE; }
@Test public void testWithCharset() { assertEquals("Unexpected produced media type content.", "UTF-8", MediaType.APPLICATION_XML_TYPE.withCharset("UTF-8") .getParameters().get(MediaType.CHARSET_PARAMETER)); assertEquals("Unexpected produced media type content.", "ISO-8859-13", MediaType.APPLICATION_XML_TYPE.withCharset("UTF-8").withCharset("ISO-8859-13") .getParameters().get(MediaType.CHARSET_PARAMETER)); }