Skip to content

Commit

Permalink
chore(formatting): Use google java formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Sep 21, 2017
1 parent 7288722 commit e4dfefc
Show file tree
Hide file tree
Showing 167 changed files with 4,141 additions and 3,556 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ jdk:
cache:
maven: true

#check coverage
before_script:
- "mvn com.coveo:fmt-maven-plugin:check"

script:
- "mvn clean test jacoco:report jacoco:report-aggregate -B && mvn -pl algoliasearch-tests coveralls:report -B"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.algolia.search;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.annotation.Nonnull;
import java.util.List;
import javax.annotation.Nonnull;

public final class AppEngineAPIClientBuilder extends APIClientBuilder {

Expand All @@ -17,7 +16,8 @@ protected APIClient build(@Nonnull APIClientConfiguration configuration) {
}

@Override
public AppEngineAPIClientBuilder setUserAgent(@Nonnull String customAgent, @Nonnull String customAgentVersion) {
public AppEngineAPIClientBuilder setUserAgent(
@Nonnull String customAgent, @Nonnull String customAgentVersion) {
super.setUserAgent(customAgent, customAgentVersion);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.appengine.api.urlfetch.*;
import com.palominolabs.http.url.UrlBuilder;

import javax.annotation.Nonnull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -20,6 +18,7 @@
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import javax.annotation.Nonnull;

class AppEngineHttpClient extends AlgoliaHttpClient {

Expand All @@ -40,11 +39,11 @@ class AppEngineHttpClient extends AlgoliaHttpClient {
this.hostDownTimeout = configuration.getHostDownTimeout();

this.fetchService = URLFetchServiceFactory.getURLFetchService();
this.defaultFetchOptions = FetchOptions
.Builder
.withDeadline(configuration.getConnectTimeout() + configuration.getReadTimeout())
.followRedirects()
.validateCertificate();
this.defaultFetchOptions =
FetchOptions.Builder.withDeadline(
configuration.getConnectTimeout() + configuration.getReadTimeout())
.followRedirects()
.validateCertificate();
}

@Override
Expand All @@ -58,8 +57,7 @@ protected AlgoliaHttpResponse request(@Nonnull AlgoliaHttpRequest request) throw
private AlgoliaHttpResponse from(final HTTPResponse httpResponse) {
return new AlgoliaHttpResponse() {
@Override
public void close() throws IOException {
}
public void close() throws IOException {}

@Override
public int getStatusCode() {
Expand All @@ -70,9 +68,7 @@ public int getStatusCode() {
public Reader getBody() throws IOException {
if (hasGzip(httpResponse.getHeaders())) {
return new InputStreamReader(
new GZIPInputStream(new ByteArrayInputStream(httpResponse.getContent())),
UTF8
);
new GZIPInputStream(new ByteArrayInputStream(httpResponse.getContent())), UTF8);
}
return new InputStreamReader(new ByteArrayInputStream(httpResponse.getContent()), UTF8);
}
Expand All @@ -81,18 +77,19 @@ public Reader getBody() throws IOException {

private boolean hasGzip(List<HTTPHeader> headers) {
for (HTTPHeader header : headers) {
if (header.getName().equalsIgnoreCase("Content-Encoding") && header.getValue().toLowerCase().contains("gzip")) {
if (header.getName().equalsIgnoreCase("Content-Encoding")
&& header.getValue().toLowerCase().contains("gzip")) {
return true;
}
}
return false;
}

protected HTTPRequest build(AlgoliaHttpRequest request) throws MalformedURLException, CharacterCodingException {
HTTPRequest httpRequest = new HTTPRequest(
toUrl(request),
HTTPMethod.valueOf(request.getMethod().name),
defaultFetchOptions);
protected HTTPRequest build(AlgoliaHttpRequest request)
throws MalformedURLException, CharacterCodingException {
HTTPRequest httpRequest =
new HTTPRequest(
toUrl(request), HTTPMethod.valueOf(request.getMethod().name), defaultFetchOptions);

for (Map.Entry<String, String> entry : headers.entrySet()) {
httpRequest.addHeader(new HTTPHeader(entry.getKey(), entry.getValue()));
Expand All @@ -109,7 +106,8 @@ protected HTTPRequest build(AlgoliaHttpRequest request) throws MalformedURLExcep
return httpRequest;
}

private URL toUrl(AlgoliaHttpRequest request) throws CharacterCodingException, MalformedURLException {
private URL toUrl(AlgoliaHttpRequest request)
throws CharacterCodingException, MalformedURLException {
UrlBuilder urlBuilder = UrlBuilder.forHost("https", request.getHost());

for (String p : request.getPath()) {
Expand Down Expand Up @@ -145,6 +143,6 @@ public int getHostDownTimeout() {

@Override
public void close() throws AlgoliaException {
//nothing to do here
// nothing to do here
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.algolia.search;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.annotation.Nonnull;
import java.util.List;
import javax.annotation.Nonnull;

public final class AsyncHttpAPIClientBuilder extends AsyncAPIClientBuilder {

Expand All @@ -17,7 +16,8 @@ protected AsyncAPIClient build(@Nonnull AsyncAPIClientConfiguration configuratio
}

@Override
public AsyncHttpAPIClientBuilder setUserAgent(@Nonnull String customAgent, @Nonnull String customAgentVersion) {
public AsyncHttpAPIClientBuilder setUserAgent(
@Nonnull String customAgent, @Nonnull String customAgentVersion) {
super.setUserAgent(customAgent, customAgentVersion);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import com.algolia.search.http.AsyncAlgoliaHttpClient;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import net.javacrumbs.futureconverter.java8guava.FutureConverter;

import javax.annotation.Nonnull;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import net.javacrumbs.futureconverter.java8guava.FutureConverter;

class AsyncHttpClient extends AsyncAlgoliaHttpClient {

Expand All @@ -22,12 +21,12 @@ class AsyncHttpClient extends AsyncAlgoliaHttpClient {

@Override
public <T> CompletableFuture<T> requestWithRetry(@Nonnull AlgoliaRequest<T> request) {
return FutureConverter.toCompletableFuture(service.submit(() -> internal.requestWithRetry(request)));
return FutureConverter.toCompletableFuture(
service.submit(() -> internal.requestWithRetry(request)));
}

@Override
public void close() throws AlgoliaException {
internal.close();
}

}
Loading

0 comments on commit e4dfefc

Please sign in to comment.