Skip to content

Commit 154f496

Browse files
authored
Merge pull request segmentio#122 from segmentio/spotless
Spotless
2 parents 7cb8bfd + 6717f30 commit 154f496

40 files changed

Lines changed: 735 additions & 440 deletions

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- checkout
1010
- restore_cache:
1111
key: maven-dep-cache-{{ checksum "pom.xml" }}
12-
- run: mvn test
12+
- run: mvn spotless:check test verify
1313
- run: mvn package -B
1414
- run: .buildscript/e2e.sh
1515
- save_cache:
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package com.segment.analytics;
22

3+
import static java.lang.annotation.RetentionPolicy.SOURCE;
4+
35
import java.lang.annotation.Documented;
46
import java.lang.annotation.Retention;
57

6-
import static java.lang.annotation.RetentionPolicy.SOURCE;
7-
88
/**
9-
* Signifies that a public API (public class, method or field) is subject to
10-
* incompatible changes, or even removal, in a future release. An API bearing
11-
* this annotation is exempt from any compatibility guarantees made by its
12-
* containing library. Note that the presence of this annotation implies nothing
13-
* about the quality or performance of the API in question, only the fact that
14-
* it is not "API-frozen."
9+
* Signifies that a public API (public class, method or field) is subject to incompatible changes,
10+
* or even removal, in a future release. An API bearing this annotation is exempt from any
11+
* compatibility guarantees made by its containing library. Note that the presence of this
12+
* annotation implies nothing about the quality or performance of the API in question, only the fact
13+
* that it is not "API-frozen."
1514
*/
16-
@Documented @Retention(SOURCE) public @interface Beta {
17-
}
15+
@Documented
16+
@Retention(SOURCE)
17+
public @interface Beta {}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package com.segment.analytics.gson;
22

3+
import static java.lang.annotation.ElementType.TYPE;
4+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
5+
36
import com.google.auto.value.AutoValue;
47
import java.lang.annotation.Retention;
58
import java.lang.annotation.Target;
69

7-
import static java.lang.annotation.ElementType.TYPE;
8-
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9-
1010
/**
1111
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
12-
* <p>
13-
* This annotation is needed because the {@linkplain Retention retention} of {@code @AutoValue}
12+
*
13+
* <p>This annotation is needed because the {@linkplain Retention retention} of {@code @AutoValue}
1414
* does not allow reflection at runtime.
1515
*/
16-
@Target(TYPE) @Retention(RUNTIME) public @interface AutoGson {
17-
}
16+
@Target(TYPE)
17+
@Retention(RUNTIME)
18+
public @interface AutoGson {}

analytics-core/src/main/java/com/segment/analytics/gson/AutoValueAdapterFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
/** A {@link TypeAdapterFactory} that allows deserialization of {@link AutoValue} classes. */
1010
public final class AutoValueAdapterFactory implements TypeAdapterFactory {
11-
@SuppressWarnings("unchecked") @Override
11+
@SuppressWarnings("unchecked")
12+
@Override
1213
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
1314
Class<? super T> rawType = type.getRawType();
1415
if (!rawType.isAnnotationPresent(AutoGson.class)) {

analytics-core/src/main/java/com/segment/analytics/gson/Iso8601Utils.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@
2626
* Moshi's date formatter, pruned to Segment's needs. Forked from this file:
2727
* https://github.com/square/moshi/blob/master/adapters/src/main/java/com/squareup/moshi/Iso8601Utils.java
2828
*
29-
* -------------------------------------------------------------------------------------------------
29+
* <p>-------------------------------------------------------------------------------------------------
3030
*
31-
* Jackson’s date formatter, pruned to Moshi's needs. Forked from this file:
31+
* <p>Jackson’s date formatter, pruned to Moshi's needs. Forked from this file:
3232
* https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java
3333
*
34-
* Utilities methods for manipulating dates in iso8601 format. This is much much faster and GC
34+
* <p>Utilities methods for manipulating dates in iso8601 format. This is much much faster and GC
3535
* friendly than using SimpleDateFormat so highly suitable if you (un)serialize lots of date
3636
* objects.
3737
*
38-
* Supported parse format: [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh[:]mm]]
38+
* <p>Supported parse format:
39+
* [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh[:]mm]]
3940
*
4041
* @see <a href="http://www.w3.org/TR/NOTE-datetime">this specification</a>
4142
*/
@@ -172,8 +173,11 @@ static Date parse(String date) throws JsonParseException {
172173
*/
173174
String cleaned = act.replace(":", "");
174175
if (!cleaned.equals(timezoneId)) {
175-
throw new IndexOutOfBoundsException("Mismatching time zone indicator: "
176-
+ timezoneId + " given, resolves to " + timezone.getID());
176+
throw new IndexOutOfBoundsException(
177+
"Mismatching time zone indicator: "
178+
+ timezoneId
179+
+ " given, resolves to "
180+
+ timezone.getID());
177181
}
178182
}
179183
}
@@ -264,8 +268,7 @@ private static void padInt(StringBuilder buffer, int value, int length) {
264268
}
265269

266270
/**
267-
* Returns the index of the first character in the string that is not a digit, starting at
268-
* offset.
271+
* Returns the index of the first character in the string that is not a digit, starting at offset.
269272
*/
270273
private static int indexOfNonDigit(String string, int offset) {
271274
for (int i = offset; i < string.length(); i++) {

analytics-core/src/main/java/com/segment/analytics/http/SegmentService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
/** REST interface for the Segment API. */
88
public interface SegmentService {
9-
@POST("/v1/import") UploadResponse upload(@Body Batch batch);
9+
@POST("/v1/import")
10+
UploadResponse upload(@Body Batch batch);
1011
}

analytics-core/src/main/java/com/segment/analytics/http/UploadResponse.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.google.auto.value.AutoValue;
44
import com.segment.analytics.gson.AutoGson;
55

6-
@AutoValue @AutoGson public abstract class UploadResponse {
6+
@AutoValue
7+
@AutoGson
8+
public abstract class UploadResponse {
79
public abstract boolean success();
810
}

analytics-core/src/main/java/com/segment/analytics/messages/AliasMessage.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
* The alias message is used to merge two user identities, effectively connecting two sets of user
1010
* data as one. This is an advanced method, but it is required to manage user identities
1111
* successfully in some of our integrations.
12-
* <p>
13-
* Use {@link #builder} to construct your own instances.
12+
*
13+
* <p>Use {@link #builder} to construct your own instances.
1414
*
1515
* @see <a href="https://segment.com/docs/spec/alias/">Alias</a>
1616
*/
17-
@AutoValue @AutoGson //
17+
@AutoValue
18+
@AutoGson //
1819
public abstract class AliasMessage implements Message {
1920

2021
/**
2122
* Start building an {@link AliasMessage} instance.
2223
*
23-
* @param previousId The previous unique identifier for the user. See the Previous ID field
24-
* docs for more detail.
24+
* @param previousId The previous unique identifier for the user. See the Previous ID field docs
25+
* for more detail.
2526
* @throws IllegalArgumentException if the previousId is null or empty
2627
*/
2728
public static Builder builder(String previousId) {
@@ -51,14 +52,21 @@ private Builder(String previousId) {
5152
this.previousId = previousId;
5253
}
5354

54-
@Override protected AliasMessage realBuild(Type type, String messageId, Date timestamp,
55-
Map<String, ?> context, String anonymousId, String userId,
55+
@Override
56+
protected AliasMessage realBuild(
57+
Type type,
58+
String messageId,
59+
Date timestamp,
60+
Map<String, ?> context,
61+
String anonymousId,
62+
String userId,
5663
Map<String, Object> integrations) {
57-
return new AutoValue_AliasMessage(type, messageId, timestamp, context, anonymousId, userId,
58-
integrations, previousId);
64+
return new AutoValue_AliasMessage(
65+
type, messageId, timestamp, context, anonymousId, userId, integrations, previousId);
5966
}
6067

61-
@Override Builder self() {
68+
@Override
69+
Builder self() {
6270
return this;
6371
}
6472
}

analytics-core/src/main/java/com/segment/analytics/messages/Batch.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import java.util.Map;
88
import java.util.concurrent.atomic.AtomicInteger;
99

10-
@AutoValue @AutoGson public abstract class Batch {
10+
@AutoValue
11+
@AutoGson
12+
public abstract class Batch {
1113
private static final AtomicInteger SEQUENCE_GENERATOR = new AtomicInteger();
1214

1315
public static Batch create(Map<String, ?> context, List<Message> batch) {
@@ -21,4 +23,4 @@ public static Batch create(Map<String, ?> context, List<Message> batch) {
2123
public abstract Map<String, ?> context();
2224

2325
public abstract int sequence();
24-
}
26+
}

analytics-core/src/main/java/com/segment/analytics/messages/GroupMessage.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
* concept! It also lets you record custom traits about the group, like industry or number of
1313
* employees. Calling group is a slightly more advanced feature, but it’s helpful if you have
1414
* accounts with multiple users.
15-
* <p>
16-
* Use {@link #builder} to construct your own instances.
15+
*
16+
* <p>Use {@link #builder} to construct your own instances.
1717
*
1818
* @see <a href="https://segment.com/docs/spec/group/">Group</a>
1919
*/
20-
@AutoValue @AutoGson //
20+
@AutoValue
21+
@AutoGson //
2122
public abstract class GroupMessage implements Message {
2223

2324
/**
@@ -33,7 +34,8 @@ public static Builder builder(String groupId) {
3334

3435
public abstract String groupId();
3536

36-
@Nullable public abstract Map<String, ?> traits();
37+
@Nullable
38+
public abstract Map<String, ?> traits();
3739

3840
public Builder toBuilder() {
3941
return new Builder(this);
@@ -71,14 +73,21 @@ public Builder traits(Map<String, ?> traits) {
7173
return this;
7274
}
7375

74-
@Override protected GroupMessage realBuild(Type type, String messageId, Date timestamp,
75-
Map<String, ?> context, String anonymousId, String userId,
76+
@Override
77+
protected GroupMessage realBuild(
78+
Type type,
79+
String messageId,
80+
Date timestamp,
81+
Map<String, ?> context,
82+
String anonymousId,
83+
String userId,
7684
Map<String, Object> integrations) {
77-
return new AutoValue_GroupMessage(type, messageId, timestamp, context, anonymousId, userId,
78-
integrations, groupId, traits);
85+
return new AutoValue_GroupMessage(
86+
type, messageId, timestamp, context, anonymousId, userId, integrations, groupId, traits);
7987
}
8088

81-
@Override Builder self() {
89+
@Override
90+
Builder self() {
8291
return this;
8392
}
8493
}

0 commit comments

Comments
 (0)