public static <K, V> ImmutableMapBuilder<K, V> of() { return new ImmutableMapBuilder<>(); }
public HttpHeaders plus(final String key, final String value) { final List<String> currentValues = headers.getOrDefault(key, Collections.emptyList()); final List<String> newValues = listOf(currentValues, value); final Map<String, List<String>> newMap = ImmutableMapBuilder.<String, List<String>>of() .putAll(headers) .put(key, newValues) .build(); return HttpHeaders.of(newMap); }
/** * LocalizedStrings containing the given entries. * @param locale the additional locale of the new entry * @param value the value for the <code>locale</code> * @return a LocalizedStrings containing this data and the from the parameters. * @throws IllegalArgumentException if duplicate locales are provided */ public LocalizedStrings plus(final Locale locale, final String value) { if (translations.containsKey(locale)) { throw new IllegalArgumentException(format("Duplicate keys (%s) for map creation.", locale)); } final Map<Locale, String> newMap = ImmutableMapBuilder.<Locale, String>of(). putAll(translations). put(locale, value). build(); return new LocalizedStrings(newMap); }