All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.http.FormUrlEncodedHttpRequestBody Maven / Gradle / Ivy

package io.sphere.sdk.http;

import java.util.*;

import static java.util.Collections.unmodifiableList;

public final class FormUrlEncodedHttpRequestBody extends Base implements HttpRequestBody {
    private final List data;

    private FormUrlEncodedHttpRequestBody(final List data) {
        this.data = unmodifiableList(new ArrayList<>(data));
    }

    public static FormUrlEncodedHttpRequestBody of(final List data) {
        return new FormUrlEncodedHttpRequestBody(data);
    }

    /**
     * Creator if the order does not matter and there are no duplicates.
     * @param data name value pairs for the body
     * @return FormUrlEncodedHttpRequestBody
     */
    public static FormUrlEncodedHttpRequestBody ofStringMap(final Map data) {
        return of(NameValuePair.convertStringMapToList(data));
    }

    /**
     * Creator if the order does not matter and there are no duplicates.
     * @param data name value pairs for the body
     * @return FormUrlEncodedHttpRequestBody
     */
    public static FormUrlEncodedHttpRequestBody of(final Map> data) {
        return of(NameValuePair.convertStringListMapToList(data));
    }

    public List getParameters() {
        return data;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy