package com.alwaysallthetime.adnlib;

import java.util.HashMap;
import java.util.List;

public class QueryParameters extends HashMap<String, String> {
    // very unlikely you'd ever need more than 4 query parameters on one request
    private static final int INITIAL_CAPACITY = 4;
    private static final float LOAD_FACTOR = 1.0f;

    public QueryParameters() {
        this(INITIAL_CAPACITY, LOAD_FACTOR);
    }

    protected QueryParameters(int capacity, float loadFactor) {
        super(capacity, loadFactor);
    }

    public QueryParameters(IQueryParameter... queryParameters) {
        super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR);
        put(queryParameters);
    }

    public void put(IQueryParameter... queryParameters) {
        for (IQueryParameter queryParameter : queryParameters) {
            put(queryParameter.getName(), queryParameter.getValue());
        }
    }

    protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) {
        final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength);
        for(final String str : strings) {
            buffer.append(str);
            buffer.append(',');
        }

        return buffer.substring(0, buffer.length() - 1);
    }
}
@@ -328,16 +328,791 @@
  1.0f;%0A%0A
+    /**%0A     * Get a new QueryParameters that consists of two sets of QueryParamters combined.%0A     *%0A     * Since it is possible that there will be conflicting parameters, the second set will be applied%0A     * %22on top of%22 the first set, i.e. the topParameters can override the bottomParameters%0A     *%0A     * @param bottomParameters%0A     * @param topParameters%0A     * @return a new QueryParamters consisting of the values form both specified QueryParameters objects.%0A     */%0A    public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) %7B%0A        QueryParameters newParams = new QueryParameters();%0A        newParams.putAll(bottomParameters);%0A        newParams.putAll(topParameters);%0A        return newParams;%0A    %7D%0A%0A
     publ

add method for combining two sets of QueryParameters