From c4ea303d1e982f2c5345b2fe39f126c355748f04 Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Fri, 3 Jan 2025 10:48:18 +1100 Subject: [PATCH] Cleaned up some nullability warnings --- .../java/org/jsoup/helper/HttpConnection.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/jsoup/helper/HttpConnection.java b/src/main/java/org/jsoup/helper/HttpConnection.java index 48a5d9c767..de55c0e5b2 100644 --- a/src/main/java/org/jsoup/helper/HttpConnection.java +++ b/src/main/java/org/jsoup/helper/HttpConnection.java @@ -266,7 +266,7 @@ public Connection data(Collection 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)) @@ -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; } @@ -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 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, ", "); } @@ -485,7 +485,7 @@ public List 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; } @@ -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) { @@ -526,7 +526,7 @@ public Map headers() { for (Map.Entry> entry : headers.entrySet()) { String header = entry.getKey(); List values = entry.getValue(); - if (values.size() > 0) + if (!values.isEmpty()) map.put(header, values.get(0)); } return map; @@ -647,7 +647,7 @@ public static class Request extends HttpConnection.Base impl executing = false; } - @Override + @Override @Nullable public Proxy proxy() { return proxy; } @@ -704,7 +704,7 @@ public boolean ignoreHttpErrors() { return ignoreHttpErrors; } - @Override + @Override @Nullable public SSLSocketFactory sslSocketFactory() { return sslSocketFactory; } @@ -749,7 +749,7 @@ public Connection.Request requestBody(@Nullable String body) { return this; } - @Override + @Override @Nullable public String requestBody() { return body; } @@ -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); @@ -948,7 +948,7 @@ public String statusMessage() { return statusMessage; } - @Override + @Override @Nullable public String charset() { return charset; } @@ -959,7 +959,7 @@ public Response charset(String charset) { return this; } - @Override + @Override @Nullable public String contentType() { return contentType; } @@ -1398,7 +1398,7 @@ public KeyVal inputStream(InputStream inputStream) { return this; } - @Override + @Override @Nullable public InputStream inputStream() { return stream; } @@ -1415,7 +1415,7 @@ public Connection.KeyVal contentType(String contentType) { return this; } - @Override + @Override @Nullable public String contentType() { return contentType; }