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

org.unitedinternet.cosmo.ext.RequestOptions Maven / Gradle / Ivy

The newest version!
package org.unitedinternet.cosmo.ext;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 
 * @author daniel grigore
 *
 */
public class RequestOptions {

    private Map headers;
    private Map queryParams;

    private RequestOptions() {

    }

    public Map headers() {
        return headers;
    }

    public Map queryParams() {
        return queryParams;
    }

    private void setHeaders(Map headers) {
        this.headers = headers;
    }

    private void setQueryParams(Map queryParams) {
        this.queryParams = queryParams;
    }

    public static RequestOptionsBuilder builder() {
        return new RequestOptionsBuilder();
    }

    public static class RequestOptionsBuilder {

        private Map headers = new LinkedHashMap<>();
        private Map queryParams = new LinkedHashMap<>();

        private RequestOptionsBuilder() {

        }

        public static RequestOptionsBuilder instance() {
            return new RequestOptionsBuilder();
        }

        public RequestOptionsBuilder withHeader(String headerName, String headerValue) {
            headers.put(headerName, headerValue);
            return this;
        }

        public RequestOptionsBuilder withQueryParam(String headerName, String headerValue) {
            this.queryParams.put(headerName, headerValue);
            return this;
        }

        public RequestOptions build() {
            RequestOptions options = new RequestOptions();
            options.setHeaders(this.headers);
            options.setQueryParams(this.queryParams);
            return options;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy