Permalink
Browse files

Added static #copy method to config classes

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk@1428917 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 24035d1 commit 518d8648e3747a6570ffd730d08eab32440c74cb @ok2c ok2c committed Jan 4, 2013
@@ -270,6 +270,21 @@ public static Builder custom() {
return new Builder();
}
+ public static Builder copy(final IOReactorConfig config) {
+ Args.notNull(config, "I/O reactor config");
+ return new Builder()
+ .setSelectInterval(config.getSelectInterval())
+ .setShutdownGracePeriod(config.getShutdownGracePeriod())
+ .setInterestOpQueued(config.isInterestOpQueued())
+ .setIoThreadCount(config.getIoThreadCount())
+ .setSoTimeout(config.getSoTimeout())
+ .setSoReuseAddress(config.isSoReuseAddress())
+ .setSoLinger(config.getSoLinger())
+ .setSoKeepAlive(config.isSoKeepalive())
+ .setTcpNoDelay(config.isTcpNoDelay())
+ .setConnectTimeout(config.getConnectTimeout());
+ }
+
public static class Builder {
private long selectInterval;
@@ -32,6 +32,7 @@
import org.apache.http.Consts;
import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
/**
* HTTP connection configuration.
@@ -96,6 +97,15 @@ public String toString() {
return new Builder();
}
+ public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
+ Args.notNull(config, "Connection config");
+ return new Builder()
+ .setCharset(config.getCharset())
+ .setMalformedInputAction(config.getMalformedInputAction())
+ .setUnmappableInputAction(config.getUnmappableInputAction())
+ .setMessageConstraints(config.getMessageConstraints());
+ }
+
public static class Builder {
private Charset charset;
@@ -77,6 +77,13 @@ public static MessageConstraints lineLen(int max) {
return new Builder();
}
+ public static MessageConstraints.Builder copy(final MessageConstraints config) {
+ Args.notNull(config, "Message constraints");
+ return new Builder()
+ .setMaxHeaderCount(config.getMaxHeaderCount())
+ .setMaxLineLength(config.getMaxLineLength());
+ }
+
public static class Builder {
private int maxLineLength;
@@ -30,6 +30,7 @@
import java.net.SocketOptions;
import org.apache.http.annotation.Immutable;
+import org.apache.http.util.Args;
/**
* Socket configuration.
@@ -141,6 +142,16 @@ public String toString() {
return new Builder();
}
+ public static SocketConfig.Builder copy(final SocketConfig config) {
+ Args.notNull(config, "Socket config");
+ return new Builder()
+ .setSoTimeout(config.getSoTimeout())
+ .setSoReuseAddress(config.isSoReuseAddress())
+ .setSoLinger(config.getSoLinger())
+ .setSoKeepAlive(config.isSoKeepAlive())
+ .setTcpNoDelay(config.isTcpNoDelay());
+ }
+
public static class Builder {
private int soTimeout;

0 comments on commit 518d864

Please sign in to comment.