/** * Adds headers to this stub response. If there already exists a header with a same name * in this stub response, multiple values will be sent. * @param headers response headers (both keys and values must be of type String) */ @SuppressWarnings("unchecked") void addHeaders(final MultiMap headers) { this.headers.putAll(headers); }
/** * Adds headers to this stub response. If there already exists a header with a same name * in this stub response, multiple values will be sent. * @param headers response headers (both keys and values must be of type String) */ @SuppressWarnings("unchecked") void addHeaders(final MultiMap headers) { this.headers.putAll(headers); }
public void putAllMultiMap(Map<? extends K, ? extends Collection<V>> t) { m_impl.putAll(t); }
/** * Adds all values from the given instance. Supports multi-values for one key (if there has already been added * some value with this key, additional value is added instead of rewriting). Please note this method * creates new instance containing all existing values plus the new ones rather than modifying this instance. * @param keyValues values to be added no(cannot be {@code null}) * @return an exact copy of this instance containing all existing values plus the new ones */ @SuppressWarnings("unchecked") public KeyValues addAll(final KeyValues keyValues) { Validate.notNull(keyValues, "keyValues cannot be null"); final KeyValues res = new KeyValues(); res.values.putAll(this.values); res.values.putAll(keyValues.values); return res; }
/** * Adds all values from the given instance. Supports multi-values for one key (if there has already been added * some value with this key, additional value is added instead of rewriting). Please note this method * creates new instance containing all existing values plus the new ones rather than modifying this instance. * @param keyValues values to be added no(cannot be {@code null}) * @return an exact copy of this instance containing all existing values plus the new ones */ @SuppressWarnings("unchecked") public KeyValues addAll(final KeyValues keyValues) { Validate.notNull(keyValues, "keyValues cannot be null"); final KeyValues res = new KeyValues(); res.values.putAll(this.values); res.values.putAll(keyValues.values); return res; }
public void setParent(ObjectModel parentObjectModel) { if (this.modified) { throw new IllegalStateException("Setting parent may occur only if Object Model is empty."); } singleValueMap.putAll(parentObjectModel); multiValueMap.putAll(parentObjectModel.getAll()); } }
/** * @param defaultHeaders default headers to be present in every http stub response * @param defaultStatus default http status of every http stub response * (can be overridden in the particular stub) * @param defaultEncoding default encoding of every stub response body (can be overridden in the particular stub) */ @SuppressWarnings("unchecked") Stubbing(final Charset defaultEncoding, final int defaultStatus, final MultiMap defaultHeaders) { this.stubResponses = new ArrayList<MutableStubResponse>(); this.defaultHeaders = new MultiValueMap(); this.defaultHeaders.putAll(defaultHeaders); this.defaultStatus = defaultStatus; this.defaultEncoding = defaultEncoding; this.responder = null; }
/** * @param defaultHeaders default headers to be present in every http stub response * @param defaultStatus default http status of every http stub response * (can be overridden in the particular stub) * @param defaultEncoding default encoding of every stub response body (can be overridden in the particular stub) */ @SuppressWarnings("unchecked") Stubbing(final Charset defaultEncoding, final int defaultStatus, final MultiMap defaultHeaders) { this.stubResponses = new ArrayList<MutableStubResponse>(); this.defaultHeaders = new MultiValueMap(); this.defaultHeaders.putAll(defaultHeaders); this.defaultStatus = defaultStatus; this.defaultEncoding = defaultEncoding; this.responder = null; }
public void putAll(Map mapToCopy) { modified = true; if (!localContexts.empty()) { ArrayStack entries = (ArrayStack)localContexts.peek(); for (Iterator keysIterator = mapToCopy.keySet().iterator(); keysIterator.hasNext();) { Object key = keysIterator.next(); entries.push(new DefaultKeyValue(key, mapToCopy.get(key))); } } singleValueMap.putAll(mapToCopy); multiValueMap.putAll(mapToCopy); }
/** * Adds new key-value pair. Supports multi-values for one key (if there has already been added * some value with this key, additional value is added instead of rewriting). Please note this method * creates new instance containing all existing values plus the new one rather than modifying this instance. * @param key key (cannot be empty) * @param value value (cannot be {@code null}, however can be empty for valueless headers) * @return an exact copy of this instance containing all existing values plus the new one */ @SuppressWarnings("unchecked") public KeyValues add(final String key, final String value) { Validate.notEmpty(key, "key cannot be empty"); Validate.notNull(value, "value cannot be null, use an empty string instead"); final KeyValues res = new KeyValues(); res.values.putAll(this.values); res.values.put(key.toLowerCase(), value); return res; }
/** * Adds new key-value pair. Supports multi-values for one key (if there has already been added * some value with this key, additional value is added instead of rewriting). Please note this method * creates new instance containing all existing values plus the new one rather than modifying this instance. * @param key key (cannot be empty) * @param value value (cannot be {@code null}, however can be empty for valueless headers) * @return an exact copy of this instance containing all existing values plus the new one */ @SuppressWarnings("unchecked") public KeyValues add(final String key, final String value) { Validate.notEmpty(key, "key cannot be empty"); Validate.notNull(value, "value cannot be null, use an empty string instead"); final KeyValues res = new KeyValues(); res.values.putAll(this.values); res.values.put(key.toLowerCase(), value); return res; }
/** * Removes all occurrences of the given header in this stub response (using a case insensitive search) * and sets its single value. * @param name header name * @param value header value */ @SuppressWarnings("unchecked") void setHeaderCaseInsensitive(final String name, final String value) { final MultiMap result = new MultiValueMap(); for (final Object o: this.headers.keySet()) { final String key = (String) o; //fucking non-generics MultiMap if (!name.equalsIgnoreCase(key)) { //copy all other headers to the result multimap for(final String s: (Collection<String>)this.headers.get(o)) { result.put(o, s); } } } this.headers.clear(); this.headers.putAll(result); this.addHeader(name, value); }
/** * Removes all occurrences of the given header in this stub response (using a case insensitive search) * and sets its single value. * @param name header name * @param value header value */ @SuppressWarnings("unchecked") void setHeaderCaseInsensitive(final String name, final String value) { final MultiMap result = new MultiValueMap(); for (final Object o: this.headers.keySet()) { final String key = (String) o; //fucking non-generics MultiMap if (!name.equalsIgnoreCase(key)) { //copy all other headers to the result multimap for(final String s: (Collection<String>)this.headers.get(o)) { result.put(o, s); } } } this.headers.clear(); this.headers.putAll(result); this.addHeader(name, value); }