MCPcopy
hub / github.com/google/guava / withCharset

Method withCharset

guava/src/com/google/common/net/MediaType.java:949–955  ·  view source on GitHub ↗

Returns a new instance with the same type and subtype as this instance, with the {@code charset} parameter set to the {@link Charset#name name} of the given charset. Only one {@code charset} parameter will be present on the new instance regardless of the number set on this one. <p>If a charset must

(Charset charset)

Source from the content-addressed store, hash-verified

947 * representable as a {@link Charset} instance), use {@link #withParameter}.
948 */
949 public MediaType withCharset(Charset charset) {
950 checkNotNull(charset);
951 MediaType withCharset = withParameter(CHARSET_ATTRIBUTE, charset.name());
952 // precache the charset so we don't need to parse it
953 withCharset.parsedCharset = Optional.of(charset);
954 return withCharset;
955 }
956
957 /** Returns true if either the type or subtype is the wildcard. */
958 public boolean hasWildcard() {

Callers 3

testWithCharsetMethod · 0.45
testEqualsMethod · 0.45

Calls 4

withParameterMethod · 0.95
ofMethod · 0.95
nameMethod · 0.65
checkNotNullMethod · 0.45

Tested by 3

testWithCharsetMethod · 0.36
testEqualsMethod · 0.36