Skip to content

Commit

Permalink
Tune check-style.xml (#344)
Browse files Browse the repository at this point in the history
* Update check-style.xml to add the Indentation configuration

* Reformat java files
  • Loading branch information
yuokada authored Jul 10, 2024
1 parent aae5ebd commit c90007e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 33 deletions.
7 changes: 7 additions & 0 deletions check-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
</module>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
<module name="EmptyStatement"/>
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad">
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/treasuredata/client/TDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ public String submit(TDJobRequest jobRequest)
buildUrl("/v3/job/issue", jobRequest.getType().getType(), jobRequest.getDatabase()),
queryParam,
jobRequest.getConfig().map((config) -> {
ObjectNode body = config.objectNode();
body.set("config", config);
return body.toString();
ObjectNode body = config.objectNode();
body.set("config", config);
return body.toString();
}),
TDJobSubmitResult.class);
return result.getJobId();
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/treasuredata/client/TDClientApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
*/
package com.treasuredata.client;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;

import com.google.common.collect.Multimap;
import com.treasuredata.client.model.TDApiKey;
import com.treasuredata.client.model.TDBulkImportSession;
Expand Down Expand Up @@ -51,8 +47,11 @@

import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

/**
Expand Down Expand Up @@ -315,7 +314,7 @@ default <Result> Result jobResult(String jobId, TDResultFormat format, com.googl
@Deprecated
default <Result> Result getBulkImportErrorRecords(String sessionName, com.google.common.base.Function<InputStream, Result> resultStreamHandler)
{
return this.getBulkImportErrorRecords(sessionName, (Function<InputStream, Result>) resultStreamHandler::apply);
return this.getBulkImportErrorRecords(sessionName, (Function<InputStream, Result>) resultStreamHandler::apply);
}

<Result> Result getBulkImportErrorRecords(String sessionName, Function<InputStream, Result> resultStreamHandler);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/treasuredata/client/TDHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ private TDHttpClient(TDClientConfig config, OkHttpClient httpClient, ObjectMappe
* Get a {@link TDHttpClient} that uses the specified headers for each request. Reuses the same
* underlying http client so closing the returned instance will return this instance as well.
*
* @deprecated Use {@link #withHeaders(Map)} instead.
* @param headers
* @return
* @deprecated Use {@link #withHeaders(Map)} instead.
*/
@Deprecated
public TDHttpClient withHeaders(Multimap<String, String> headers)
Expand Down Expand Up @@ -324,7 +324,7 @@ else if (apiRequest.getContent().isPresent()) {
}
}
else if (queryStr.length() > 0) {
request = request.put(createRequestBodyWithoutCharset(mediaTypeXwwwFormUrlencoded, queryStr));
request = request.put(createRequestBodyWithoutCharset(mediaTypeXwwwFormUrlencoded, queryStr));
}
else {
// We should set content-length explicitly for an empty put
Expand Down Expand Up @@ -525,12 +525,12 @@ public String call(TDApiRequest apiRequest, Optional<String> apiKeyCache)
}

/**
* @deprecated Use {@link #call(TDApiRequest, Optional, Function)} instead.
* @param apiRequest
* @param apiKeyCache
* @param contentStreamHandler
* @param <Result>
* @return
* @deprecated Use {@link #call(TDApiRequest, Optional, Function)} instead.
*/
@Deprecated
public <Result> Result call(TDApiRequest apiRequest, Optional<String> apiKeyCache, final com.google.common.base.Function<InputStream, Result> contentStreamHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TDBulkLoadSessionStartRequest
TDBulkLoadSessionStartRequest(
@JsonProperty("scheduled_time") String scheduledTime,
@JsonProperty("domain_key") String domainKey
)
)
{
this.scheduledTime = scheduledTime;
this.domainKey = domainKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public TDSavedQuery(
@JsonProperty("result") String result,
@JsonProperty("next_time") String nextTime,
@JsonProperty("engine_version") TDJob.EngineVersion engineVersion
)
)
{
this.id = id;
this.name = name;
Expand Down
41 changes: 21 additions & 20 deletions src/test/java/com/treasuredata/client/model/TestTDColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
*
*/
Expand Down Expand Up @@ -257,27 +258,27 @@ public void serializableTest()
}

private static void checkJsonSerDe(TDColumn column)
throws IOException
throws IOException
{
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(column);
TDColumn value = mapper.readValue(json, TDColumn.class);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(column);
TDColumn value = mapper.readValue(json, TDColumn.class);

assertEquals(value.getName(), column.getName());
assertEquals(value.getType(), column.getType());
assertTrue(Arrays.equals(value.getKey(), column.getKey()));
}
assertEquals(value.getName(), column.getName());
assertEquals(value.getType(), column.getType());
assertTrue(Arrays.equals(value.getKey(), column.getKey()));
}

@Test
public void jsonSerDeTest()
throws Exception
{
checkJsonSerDe(new TDColumn("int", TDColumnType.INT));
checkJsonSerDe(new TDColumn("str", TDColumnType.STRING, "hello".getBytes(StandardCharsets.UTF_8)));
checkJsonSerDe(new TDColumn("long", TDColumnType.LONG));
checkJsonSerDe(new TDColumn("double", TDColumnType.DOUBLE, "world".getBytes(StandardCharsets.UTF_8)));
checkJsonSerDe(new TDColumn("float", TDColumnType.FLOAT));
checkJsonSerDe(new TDColumn("array_string", newArrayType(TDColumnType.STRING)));
checkJsonSerDe(new TDColumn("map_string", newMapType(TDColumnType.INT, TDColumnType.STRING)));
}
@Test
public void jsonSerDeTest()
throws Exception
{
checkJsonSerDe(new TDColumn("int", TDColumnType.INT));
checkJsonSerDe(new TDColumn("str", TDColumnType.STRING, "hello".getBytes(StandardCharsets.UTF_8)));
checkJsonSerDe(new TDColumn("long", TDColumnType.LONG));
checkJsonSerDe(new TDColumn("double", TDColumnType.DOUBLE, "world".getBytes(StandardCharsets.UTF_8)));
checkJsonSerDe(new TDColumn("float", TDColumnType.FLOAT));
checkJsonSerDe(new TDColumn("array_string", newArrayType(TDColumnType.STRING)));
checkJsonSerDe(new TDColumn("map_string", newMapType(TDColumnType.INT, TDColumnType.STRING)));
}
}

0 comments on commit c90007e

Please sign in to comment.