/** * Replaces the values for the given key with the given values. * * @param key The key * @param values The new values * @return This object */ public FluentCaseInsensitiveStringsMap replaceWith(final String key, final Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); String lcKkey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKkey); if (nonNullValues == null) { keyLookup.remove(lcKkey); if (realKey != null) { this.values.remove(realKey); } } else { if (!key.equals(realKey)) { keyLookup.put(lcKkey, key); this.values.remove(realKey); } this.values.put(key, nonNullValues); } } return this; }
/** * Adds the specified values and returns this object. * * @param key The key * @param values The value(s); if null then this method has no effect. Use an empty collection * to generate an empty value * @return This object */ public FluentCaseInsensitiveStringsMap add(String key, Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); if (nonNullValues != null) { String lcKey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKey); List<String> curValues = null; if (realKey == null) { realKey = key; keyLookup.put(lcKey, key); } else { curValues = this.values.get(realKey); } if (curValues == null) { curValues = new ArrayList<>(); this.values.put(realKey, curValues); } curValues.addAll(nonNullValues); } } return this; }
/** * Replaces the values for the given key with the given values. * * @param key The key * @param values The new values * @return This object */ public FluentCaseInsensitiveStringsMap replace(final String key, final Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); String lcKkey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKkey); if (nonNullValues == null) { keyLookup.remove(lcKkey); if (realKey != null) { this.values.remove(realKey); } } else { if (!key.equals(realKey)) { keyLookup.put(lcKkey, key); this.values.remove(realKey); } this.values.put(key, nonNullValues); } } return this; }
/** * Replaces the values for the given key with the given values. * * @param key The key * @param values The new values * @return This object */ public FluentCaseInsensitiveStringsMap replaceWith(final String key, final Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); String lcKkey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKkey); if (nonNullValues == null) { keyLookup.remove(lcKkey); if (realKey != null) { this.values.remove(realKey); } } else { if (!key.equals(realKey)) { keyLookup.put(lcKkey, key); this.values.remove(realKey); } this.values.put(key, nonNullValues); } } return this; }
/** * Replaces the values for the given key with the given values. * * @param key The key * @param values The new values * @return This object */ public FluentCaseInsensitiveStringsMap replaceWith(final String key, final Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); String lcKkey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKkey); if (nonNullValues == null) { keyLookup.remove(lcKkey); if (realKey != null) { this.values.remove(realKey); } } else { if (!key.equals(realKey)) { keyLookup.put(lcKkey, key); this.values.remove(realKey); } this.values.put(key, nonNullValues); } } return this; }
/** * Adds the specified values and returns this object. * * @param key The key * @param values The value(s); if null then this method has no effect. Use an empty collection * to generate an empty value * @return This object */ public FluentCaseInsensitiveStringsMap add(String key, Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); if (nonNullValues != null) { String lcKey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKey); List<String> curValues = null; if (realKey == null) { realKey = key; keyLookup.put(lcKey, key); } else { curValues = this.values.get(realKey); } if (curValues == null) { curValues = new ArrayList<>(); this.values.put(realKey, curValues); } curValues.addAll(nonNullValues); } } return this; }
/** * Adds the specified values and returns this object. * * @param key The key * @param values The value(s); if null then this method has no effect. Use an empty collection * to generate an empty value * @return This object */ public FluentCaseInsensitiveStringsMap add(String key, Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); if (nonNullValues != null) { String lcKey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKey); List<String> curValues = null; if (realKey == null) { realKey = key; keyLookup.put(lcKey, key); } else { curValues = this.values.get(realKey); } if (curValues == null) { curValues = new ArrayList<String>(); this.values.put(realKey, curValues); } curValues.addAll(nonNullValues); } } return this; }
/** * Adds the specified values and returns this object. * * @param key The key * @param values The value(s); if null then this method has no effect. Use an empty collection * to generate an empty value * @return This object */ public FluentCaseInsensitiveStringsMap add(String key, Collection<String> values) { if (key != null) { List<String> nonNullValues = fetchValues(values); if (nonNullValues != null) { String lcKey = key.toLowerCase(Locale.ENGLISH); String realKey = keyLookup.get(lcKey); List<String> curValues = null; if (realKey == null) { realKey = key; keyLookup.put(lcKey, key); } else { curValues = this.values.get(realKey); } if (curValues == null) { curValues = new ArrayList<>(); this.values.put(realKey, curValues); } curValues.addAll(nonNullValues); } } return this; }