ContentType { public static ContentType create(final ContentType contentType, final String parameterName, final String parameterValue) throws IllegalArgumentException { TypeUtil.validateParameterNameAndValue(parameterName, parameterValue); ContentType type = new ContentType(contentType.type, contentType.subtype, contentType.parameters); type.parameters.put(parameterName.toLowerCase(Locale.ROOT), parameterValue); return type; } private  ContentType(final String type, final String subtype, final Map<String, String> parameters); static ContentType create(final ContentType contentType,
      final String parameterName, final String parameterValue); static ContentType create(final String format); static ContentType parse(final String format); String getType(); String getSubtype(); Map<String, String> getParameters(); String getParameter(final String name); @Override int hashCode(); @Override boolean equals(final Object obj); boolean isCompatible(final ContentType other); String toContentTypeString(); @Override String toString(); static final String PARAMETER_CHARSET; static final String PARAMETER_IEEE754_COMPATIBLE; static final String PARAMETER_ODATA_METADATA; static final String VALUE_ODATA_METADATA_NONE; static final String VALUE_ODATA_METADATA_MINIMAL; static final String VALUE_ODATA_METADATA_FULL; static final ContentType APPLICATION_JSON; static final ContentType JSON; static final ContentType JSON_NO_METADATA; static final ContentType JSON_FULL_METADATA; static final ContentType APPLICATION_XML; static final ContentType APPLICATION_ATOM_XML; static final ContentType APPLICATION_ATOM_XML_ENTRY; static final ContentType APPLICATION_ATOM_XML_ENTRY_UTF8; static final ContentType APPLICATION_ATOM_XML_FEED; static final ContentType APPLICATION_ATOM_XML_FEED_UTF8; static final ContentType APPLICATION_ATOM_SVC; static final ContentType APPLICATION_OCTET_STREAM; static final ContentType APPLICATION_XHTML_XML; static final ContentType TEXT_HTML; static final ContentType TEXT_XML; static final ContentType TEXT_PLAIN; static final ContentType APPLICATION_SVG_XML; static final ContentType APPLICATION_FORM_URLENCODED; static final ContentType APPLICATION_HTTP; static final ContentType MULTIPART_MIXED; static final ContentType MULTIPART_FORM_DATA; }
@Test public void create() { assertEquals("a/b", ContentType.create("a/b").toContentTypeString()); assertEquals(ContentType.create("a/b;c=d;x=y"), ContentType.create("a/b;x=y;c=d")); assertEquals(ContentType.create("a/b;c=d;x=y"), ContentType.create("a/b; x=y; c=d")); assertEquals(ContentType.create("A/B"), ContentType.create("a/b")); }
@Test public void createWithParameter() { assertEquals(ContentType.create("a/b;c=d"), ContentType.create(ContentType.create("a/b"), "c", "d")); assertEquals(ContentType.create("a/b;e=f;c=d"), ContentType.create( ContentType.create(ContentType.create("a/b"), "c", "d"), "e", "f")); assertEquals(ContentType.create("a/b;e=f;c=d"), ContentType.create( ContentType.create(ContentType.create("A/B"), "C", "D"), "E", "F")); }