package com.github.arteam.dropwizard.http2.client;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.arteam.dropwizard.http2.client.transport.Http2ClientTransportFactory;
import com.github.arteam.dropwizard.http2.client.transport.ClientTransportFactory;
import com.google.common.base.MoreObjects;
import io.dropwizard.util.Duration;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * The external configuration class for {@link Http2ClientBuilder}.
 */
public class Http2ClientConfiguration {

    @NotNull
    private Duration connectionTimeout = Duration.milliseconds(500);

    @NotNull
    private Duration idleTimeout = Duration.minutes(1);

    @Min(1)
    private int selectors = 1;

    private boolean storeCookies = false;

    private boolean followRedirects = true;

    @NotNull
    @Valid
    private ClientTransportFactory connectionFactoryBuilder = new Http2ClientTransportFactory();

    @JsonProperty
    public Duration getConnectionTimeout() {
        return connectionTimeout;
    }

    @JsonProperty
    public void setConnectionTimeout(Duration connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }

    @JsonProperty
    public Duration getIdleTimeout() {
        return idleTimeout;
    }

    @JsonProperty
    public void setIdleTimeout(Duration idleTimeout) {
        this.idleTimeout = idleTimeout;
    }

    @JsonProperty
    public int getSelectors() {
        return selectors;
    }

    @JsonProperty
    public void setSelectors(int selectors) {
        this.selectors = selectors;
    }

    @JsonProperty("connectionFactory")
    public ClientTransportFactory getConnectionFactoryBuilder() {
        return connectionFactoryBuilder;
    }

    @JsonProperty("connectionFactory")
    public void setConnectionFactoryBuilder(ClientTransportFactory connectionFactoryBuilder) {
        this.connectionFactoryBuilder = connectionFactoryBuilder;
    }

    @JsonProperty
    public boolean isStoreCookies() {
        return storeCookies;
    }

    @JsonProperty
    public void setStoreCookies(boolean storeCookies) {
        this.storeCookies = storeCookies;
    }

    public boolean isFollowRedirects() {
        return followRedirects;
    }

    public void setFollowRedirects(boolean followRedirects) {
        this.followRedirects = followRedirects;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("connectionTimeout", connectionTimeout)
                .add("idleTimeout", idleTimeout)
                .add("selectors", selectors)
                .add("storeCookies", storeCookies)
                .add("connectionFactoryBuilder", connectionFactoryBuilder)
                .toString();
    }
}

@@ -158,21 +158,16 @@
 ansport.
-Http2
 ClientTr
@@ -233,32 +233,37 @@
 lient.transport.
+Http2
 ClientTransportF
@@ -385,49 +385,8 @@
 id;%0A
-import javax.validation.constraints.Min;%0A
 impo
@@ -544,16 +544,88 @@
 tion %7B%0A%0A
+    /**%0A     * The max waiting time to connect to a destination%0A     */%0A
     @Not
@@ -707,205 +707,467 @@
     
-@NotNull%0A    private Duration idleTimeout = Duration.minutes(1);%0A%0A    @Min(1)%0A    private int selectors = 1;%0A%0A    private boolean storeCookies = false;%0A%0A    private boolean followRedirects = true;%0A
+/**%0A     * The max time a connection can be idle. It's the request timeout as well.%0A     */%0A    @NotNull%0A    private Duration idleTimeout = Duration.minutes(1);%0A%0A    /**%0A     * Should the client save cookies%0A     */%0A    private boolean storeCookies = false;%0A%0A    /**%0A     * Should the client follow redirects%0A     */%0A    private boolean followRedirects = true;%0A%0A    /**%0A     * A factory for providing the transport and SSL configuration for the client%0A     */
 %0A   
@@ -1749,198 +1749,8 @@
  %7D%0A%0A
-    @JsonProperty%0A    public int getSelectors() %7B%0A        return selectors;%0A    %7D%0A%0A    @JsonProperty%0A    public void setSelectors(int selectors) %7B%0A        this.selectors = selectors;%0A    %7D%0A%0A
     
@@ -2747,78 +2747,90 @@
 d(%22s
-electors%22, selectors)%0A                .add(%22storeCookies%22, storeCookie
+toreCookies%22, storeCookies)%0A                .add(%22followRedirects%22, followRedirect
 s)%0A 

Add documentation to the configuration