Skip to content

Commit

Permalink
(jcabi#178) Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Jun 26, 2020
1 parent 4253c5d commit 2e03bc3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 44 deletions.
12 changes: 7 additions & 5 deletions src/main/java/com/jcabi/http/Wire.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* Wire.
*
* <p>An instance of this interface can be used in
* {@link Request#through(Class,Object...)} to decorate
* {@link Request#through(Class, Object...)} to decorate
* an existing {@code wire}, for example:
*
* <pre> String html = new JdkRequest("http://google.com")
Expand Down Expand Up @@ -72,10 +72,12 @@ public interface Wire {
* @return Response obtained
* @throws IOException if fails
*/
Response send(Request req, String home, String method,
Collection<Map.Entry<String, String>> headers,
InputStream content, int connect, int read,
SSLContext sslcontext)
Response send(
Request req, String home, String method,
Collection<Map.Entry<String, String>> headers,
InputStream content, int connect, int read,
SSLContext sslcontext
)
throws IOException;

}
42 changes: 24 additions & 18 deletions src/main/java/com/jcabi/http/request/ApacheRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,31 @@ public final class ApacheRequest implements Request {
private static final Wire WIRE = new Wire() {
// @checkstyle ParameterNumber (6 lines)
@Override
public Response send(final Request req, final String home,
public Response send(
final Request req, final String home,
final String method,
final Collection<Map.Entry<String, String>> headers,
final InputStream content,
final int connect,
final int read,
final SSLContext sslcontext) throws IOException {
final SSLContext sslcontext
) throws IOException {
final CloseableHttpClient client = HttpClientBuilder.create()
.useSystemProperties()
.setSSLContext(sslcontext)
.build();
.useSystemProperties()
.setSSLContext(sslcontext)
.build();
try (CloseableHttpResponse response = client.execute(
this.httpRequest(
home, method, headers, content,
connect, read
)
this.httpRequest(
home, method, headers, content,
connect, read
)
)) {
return new DefaultResponse(
req,
response.getStatusLine().getStatusCode(),
response.getStatusLine().getReasonPhrase(),
this.headers(response.getAllHeaders()),
this.consume(response.getEntity())
req,
response.getStatusLine().getStatusCode(),
response.getStatusLine().getReasonPhrase(),
this.headers(response.getAllHeaders()),
this.consume(response.getEntity())
);
}
}
Expand All @@ -121,12 +123,14 @@ public Response send(final Request req, final String home,
* @throws IOException If an IO Exception occurs
* @checkstyle ParameterNumber (6 lines)
*/
public HttpEntityEnclosingRequestBase httpRequest(final String home,
public HttpEntityEnclosingRequestBase httpRequest(
final String home,
final String method,
final Collection<Map.Entry<String, String>> headers,
final InputStream content,
final int connect,
final int read) throws IOException {
final int read
) throws IOException {
final HttpEntityEnclosingRequestBase req =
new HttpEntityEnclosingRequestBase() {
@Override
Expand Down Expand Up @@ -270,8 +274,10 @@ public Response fetch(final InputStream stream) throws IOException {
}

@Override
public <T extends Wire> Request through(final Class<T> type,
final Object... args) {
public <T extends Wire> Request through(
final Class<T> type,
final Object... args
) {
return this.base.through(type, args);
}

Expand Down
51 changes: 30 additions & 21 deletions src/main/java/com/jcabi/http/request/BaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
import java.util.Map;
import javax.json.Json;
import javax.json.JsonStructure;
import javax.ws.rs.core.HttpHeaders;
import javax.net.ssl.SSLContext;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.UriBuilder;
import lombok.EqualsAndHashCode;

Expand All @@ -81,7 +81,8 @@
// first one, since maybe qulice is counting the methods in the inner
// classes too - if it doesn't, then it can be left.
//@checkstyle LineLength (1 line)
@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass", "PMD.ExcessiveImports"})
@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass",
"PMD.ExcessiveImports"})
public final class BaseRequest implements Request {

/**
Expand Down Expand Up @@ -164,9 +165,11 @@ public BaseRequest(final Wire wre, final String uri) {
* @param method HTTP method
* @param body HTTP request body
*/
public BaseRequest(final Wire wre, final String uri,
public BaseRequest(
final Wire wre, final String uri,
final Iterable<Map.Entry<String, String>> headers,
final String method, final byte[] body) {
final String method, final byte[] body
) {
this(wre, uri, headers, method, body, 0, 0);
//@checkstyle ParameterNumber (15 lines)
}
Expand All @@ -181,10 +184,12 @@ public BaseRequest(final Wire wre, final String uri,
* @param cnct Connect timeout for http connection
* @param rdd Read timeout for http connection
*/
public BaseRequest(final Wire wre, final String uri,
public BaseRequest(
final Wire wre, final String uri,
final Iterable<Map.Entry<String, String>> headers,
final String method, final byte[] body,
final int cnct, final int rdd) {
final int cnct, final int rdd
) {
this(wre, uri, headers, method, body, cnct, rdd, null);
}

Expand All @@ -200,11 +205,13 @@ public BaseRequest(final Wire wre, final String uri,
* @param context The SSL context to use
* @checkstyle ParameterNumber (5 lines)
*/
public BaseRequest(final Wire wre, final String uri,
final Iterable<Map.Entry<String, String>> headers,
final String method, final byte[] body,
final int cnct, final int rdd,
final SSLContext context) {
public BaseRequest(
final Wire wre, final String uri,
final Iterable<Map.Entry<String, String>> headers,
final String method, final byte[] body,
final int cnct, final int rdd,
final SSLContext context
) {
this.wire = wre;
this.home = BaseRequest.createUri(uri).toString();
this.hdrs = new Array<>(headers);
Expand All @@ -218,14 +225,14 @@ public BaseRequest(final Wire wre, final String uri,
@Override
public Request sslcontext(final SSLContext context) {
return new BaseRequest(
this.wire,
this.home,
this.hdrs,
this.mtd,
this.content,
this.connect,
this.read,
context
this.wire,
this.home,
this.hdrs,
this.mtd,
this.content,
this.connect,
this.read,
context
);
}

Expand Down Expand Up @@ -320,8 +327,10 @@ public Response fetch(final InputStream stream) throws IOException {
}

@Override
public <T extends Wire> Request through(final Class<T> type,
final Object... args) {
public <T extends Wire> Request through(
final Class<T> type,
final Object... args
) {
Constructor<?> ctor = null;
for (final Constructor<?> opt : type.getDeclaredConstructors()) {
if (opt.getParameterTypes().length == args.length + 1) {
Expand Down

0 comments on commit 2e03bc3

Please sign in to comment.