@Test public void testParse() throws Exception { MediaType mediaType = parse("text/plain;boundary=foo;charset=utf-8"); assertEquals("text", mediaType.type()); assertEquals("plain", mediaType.subtype()); assertEquals("UTF-8", mediaType.charset().name()); assertEquals("text/plain;boundary=foo;charset=utf-8", mediaType.toString()); assertTrue(mediaType.equals(parse("text/plain;boundary=foo;charset=utf-8"))); assertEquals(mediaType.hashCode(), parse("text/plain;boundary=foo;charset=utf-8").hashCode()); }
public static @Nullable MediaType parse(String string) { try { return get(string); } catch (IllegalArgumentException ignored) { return null; } }
MediaType { public static @Nullable MediaType parse(String string) { try { return get(string); } catch (IllegalArgumentException ignored) { return null; } } }
MediaType { public static @Nullable MediaType parse(String string) { try { return get(string); } catch (IllegalArgumentException ignored) { return null; } } private  MediaType(String mediaType, String type, String subtype, @Nullable String charset); }
MediaType { public static @Nullable MediaType parse(String string) { try { return get(string); } catch (IllegalArgumentException ignored) { return null; } } private  MediaType(String mediaType, String type, String subtype, @Nullable String charset); static MediaType valueOf(String string); static @Nullable MediaType parse(String string); static MediaType get(String string); String type(); String subtype(); @Nullable Charset charset(); @Nullable Charset charset(@Nullable Charset defaultValue); boolean isCompatible(MediaType other); boolean isSimilar(MediaType other); @Override String toString(); @Override boolean equals(@Nullable Object other); @Override int hashCode(); }
MediaType { public static @Nullable MediaType parse(String string) { try { return get(string); } catch (IllegalArgumentException ignored) { return null; } } private  MediaType(String mediaType, String type, String subtype, @Nullable String charset); static MediaType valueOf(String string); static @Nullable MediaType parse(String string); static MediaType get(String string); String type(); String subtype(); @Nullable Charset charset(); @Nullable Charset charset(@Nullable Charset defaultValue); boolean isCompatible(MediaType other); boolean isSimilar(MediaType other); @Override String toString(); @Override boolean equals(@Nullable Object other); @Override int hashCode(); static final MediaType WILDCARD; static final MediaType TEXT; static final MediaType TEXT_UTF8; }