MCPcopy Create free account
hub / github.com/antlr/codebuff / withParameter

Method withParameter

output/java_guava/1.4.18/MediaType.java:758–773  ·  view source on GitHub ↗

Replaces all parameters with the given attribute with a single parameter with the given value. If multiple parameters with the same attributes are necessary use #withParameters. Prefer #withCharset for setting the charset parameter when using a Charset object

(String attribute, String value)

Source from the content-addressed store, hash-verified

756
757
758 public MediaType withParameter(String attribute, String value) {
759 checkNotNull(attribute);
760 checkNotNull(value);
761 String normalizedAttribute = normalizeToken(attribute);
762 ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
763 for (Entry<String, String> entry : parameters.entries()) {
764 String key = entry.getKey();
765 if (!normalizedAttribute.equals(key)) {
766 builder.put(key, entry.getValue());
767 }
768 }
769 builder.put(normalizedAttribute, normalizeParameterValue(normalizedAttribute, value));
770 MediaType mediaType = new MediaType(type, subtype, builder.build());
771 // Return one of the constants if the media type is a known type.
772 return MoreObjects.firstNonNull(KNOWN_TYPES.get(mediaType), mediaType);
773 }
774
775 /**
776 * Returns a new instance with the same type and subtype as this instance, with the

Callers 1

withCharsetMethod · 0.95

Calls 12

normalizeTokenMethod · 0.95
builderMethod · 0.95
firstNonNullMethod · 0.95
entriesMethod · 0.65
getKeyMethod · 0.65
equalsMethod · 0.65
putMethod · 0.65
getValueMethod · 0.65
getMethod · 0.65
checkNotNullMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected