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

com.netopyr.reduxfx.driver.http.command.HttpPutCommand Maven / Gradle / Ivy

package com.netopyr.reduxfx.driver.http.command;

import com.netopyr.reduxfx.updater.Command;
import io.vavr.collection.HashMap;
import io.vavr.collection.Map;
import io.vavr.control.Option;
import io.vavr.control.Try;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.net.URL;
import java.util.function.Function;

@SuppressWarnings({"WeakerAccess", "unused"})
public final class HttpPutCommand implements Command {

    private final URL url;
    private final Map headers;
    private final String body;
    private final Option, Object>> actionMapper;

    public HttpPutCommand(URL url, String body, Function, Object> actionMapper) {
        this(url, HashMap.empty(), body, actionMapper);
    }
    public HttpPutCommand(URL url, Map headers, String body, Function, Object> actionMapper) {
        this.url = url;
        this.headers = headers;
        this.body = body;
        this.actionMapper = Option.of(actionMapper);
    }

    public HttpPutCommand(URL url, String body) {
        this(url, HashMap.empty(), body);
    }
    public HttpPutCommand(URL url, Map headers, String body) {
        this.url = url;
        this.headers = headers;
        this.body = body;
        this.actionMapper = Option.none();
    }

    public URL getUrl() {
        return url;
    }

    public Map getHeaders() {
        return headers;
    }

    public String getBody() {
        return body;
    }

    public Option, Object>> getActionMapper() {
        return actionMapper;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
                .append("url", url)
                .append("headers", headers)
                .append("body", body)
                .append("actionMapper", actionMapper)
                .toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy