Skip to content

Commit c6f7fd9

Browse files
author
Stephane Landelle
committed
Minor clean up
1 parent ea0763c commit c6f7fd9

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/main/java/com/ning/http/client/FluentStringsMap.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package com.ning.http.client;
1818

19+
import static com.ning.http.util.MiscUtil.isNonEmpty;
20+
1921
import java.util.ArrayList;
2022
import java.util.Arrays;
2123
import java.util.Collection;
@@ -61,7 +63,7 @@ public FluentStringsMap(Map<String, Collection<String>> src) {
6163
* @return This object
6264
*/
6365
public FluentStringsMap add(String key, String... values) {
64-
if ((values != null) && (values.length > 0)) {
66+
if (isNonEmpty(values)) {
6567
add(key, Arrays.asList(values));
6668
}
6769
return this;

src/main/java/com/ning/http/client/RequestBuilderBase.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public abstract class RequestBuilderBase<T extends RequestBuilderBase<T>> {
4949

5050
private static final class RequestImpl implements Request {
5151
private String method;
52-
private URI originalUri = null;
53-
private URI uri = null;
54-
private URI rawUri = null;
55-
private InetAddress address = null;
56-
private InetAddress localAddress = null;
52+
private URI originalUri;
53+
private URI uri;
54+
private URI rawUri;
55+
private InetAddress address;
56+
private InetAddress localAddress;
5757
private FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap();
5858
private Collection<Cookie> cookies = new ArrayList<Cookie>();
5959
private byte[] byteData;
@@ -71,9 +71,9 @@ private static final class RequestImpl implements Request {
7171
private File file;
7272
private Boolean followRedirects;
7373
private PerRequestConfig perRequestConfig;
74-
private long rangeOffset = 0;
74+
private long rangeOffset;
7575
public String charset;
76-
private boolean useRawUrl = false;
76+
private boolean useRawUrl;
7777
private ConnectionPoolKeyStrategy connectionPoolKeyStrategy = DefaultConnectionPoolStrategy.INSTANCE;
7878

7979
public RequestImpl(boolean useRawUrl) {
@@ -93,9 +93,9 @@ public RequestImpl(Request prototype) {
9393
this.streamData = prototype.getStreamData();
9494
this.entityWriter = prototype.getEntityWriter();
9595
this.bodyGenerator = prototype.getBodyGenerator();
96-
this.params = (prototype.getParams() == null ? null : new FluentStringsMap(prototype.getParams()));
97-
this.queryParams = (prototype.getQueryParams() == null ? null : new FluentStringsMap(prototype.getQueryParams()));
98-
this.parts = (prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts()));
96+
this.params = prototype.getParams() == null ? null : new FluentStringsMap(prototype.getParams());
97+
this.queryParams = prototype.getQueryParams() == null ? null : new FluentStringsMap(prototype.getQueryParams());
98+
this.parts = prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts());
9999
this.virtualHost = prototype.getVirtualHost();
100100
this.length = prototype.getContentLength();
101101
this.proxyServer = prototype.getProxyServer();

src/main/java/com/ning/http/util/MiscUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ private MiscUtil() {
2323
public static boolean isNonEmpty(String string) {
2424
return string != null && string.length() != 0;
2525
}
26+
27+
public static boolean isNonEmpty(Object[] array) {
28+
return array != null && array.length != 0;
29+
}
2630

2731
public static boolean isNonEmpty(Collection<?> collection) {
2832
return collection != null && !collection.isEmpty();

0 commit comments

Comments
 (0)