Skip to content

Commit

Permalink
Cleaned up some nullability warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Jan 2, 2025
1 parent a908dc9 commit c4ea303
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public Connection data(Collection<Connection.KeyVal> data) {
}

@Override
public Connection.KeyVal data(String key) {
public Connection.@Nullable KeyVal data(String key) {
Validate.notEmptyParam(key, "key");
for (Connection.KeyVal keyVal : request().data()) {
if (keyVal.key().equals(key))
Expand Down Expand Up @@ -382,7 +382,7 @@ public Connection postDataCharset(String charset) {
return this;
}

@Override public Connection auth(RequestAuthenticator authenticator) {
@Override public Connection auth(@Nullable RequestAuthenticator authenticator) {
req.auth(authenticator);
return this;
}
Expand Down Expand Up @@ -449,11 +449,11 @@ public T method(Method method) {
return (T) this;
}

@Override
@Override @Nullable
public String header(String name) {
Validate.notNullParam(name, "name");
List<String> vals = getHeadersCaseInsensitive(name);
if (vals.size() > 0) {
if (!vals.isEmpty()) {
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
return StringUtil.join(vals, ", ");
}
Expand Down Expand Up @@ -485,7 +485,7 @@ public List<String> headers(String name) {
@Override
public T header(String name, String value) {
Validate.notEmptyParam(name, "name");
removeHeader(name); // ensures we don't get an "accept-encoding" and a "Accept-Encoding"
removeHeader(name); // ensures we don't get an "accept-encoding" and an "Accept-Encoding"
addHeader(name, value);
return (T) this;
}
Expand All @@ -497,7 +497,7 @@ public boolean hasHeader(String name) {
}

/**
* Test if the request has a header with this value (case insensitive).
* Test if the request has a header with this value (case-insensitive).
*/
@Override
public boolean hasHeaderWithValue(String name, String value) {
Expand Down Expand Up @@ -526,7 +526,7 @@ public Map<String, String> headers() {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String header = entry.getKey();
List<String> values = entry.getValue();
if (values.size() > 0)
if (!values.isEmpty())
map.put(header, values.get(0));
}
return map;
Expand Down Expand Up @@ -647,7 +647,7 @@ public static class Request extends HttpConnection.Base<Connection.Request> impl
executing = false;
}

@Override
@Override @Nullable
public Proxy proxy() {
return proxy;
}
Expand Down Expand Up @@ -704,7 +704,7 @@ public boolean ignoreHttpErrors() {
return ignoreHttpErrors;
}

@Override
@Override @Nullable
public SSLSocketFactory sslSocketFactory() {
return sslSocketFactory;
}
Expand Down Expand Up @@ -749,7 +749,7 @@ public Connection.Request requestBody(@Nullable String body) {
return this;
}

@Override
@Override @Nullable
public String requestBody() {
return body;
}
Expand Down Expand Up @@ -847,7 +847,7 @@ static Response execute(HttpConnection.Request req, @Nullable Response previousR

// set up the request for execution
String mimeBoundary = null;
if (req.data().size() > 0 && (!methodHasBody || hasRequestBody))
if (!req.data().isEmpty() && (!methodHasBody || hasRequestBody))
serialiseRequestUrl(req);
else if (methodHasBody)
mimeBoundary = setOutputContentType(req);
Expand Down Expand Up @@ -948,7 +948,7 @@ public String statusMessage() {
return statusMessage;
}

@Override
@Override @Nullable
public String charset() {
return charset;
}
Expand All @@ -959,7 +959,7 @@ public Response charset(String charset) {
return this;
}

@Override
@Override @Nullable
public String contentType() {
return contentType;
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ public KeyVal inputStream(InputStream inputStream) {
return this;
}

@Override
@Override @Nullable
public InputStream inputStream() {
return stream;
}
Expand All @@ -1415,7 +1415,7 @@ public Connection.KeyVal contentType(String contentType) {
return this;
}

@Override
@Override @Nullable
public String contentType() {
return contentType;
}
Expand Down

0 comments on commit c4ea303

Please sign in to comment.