Skip to content

Commit 55350a7

Browse files
author
Cameron Mace
authored
Merge pull request #188 from mapbox/checkstyle-fixes-round-1
Fixed commons package content
2 parents 6d0617c + e688c32 commit 55350a7

33 files changed

Lines changed: 2494 additions & 2469 deletions

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ If you want to contribute code:
1010

1111
3. Pull requests are gladly accepted. If there are any changes that developers should be aware of, please update the [change log](CHANGELOG.md)
1212

13+
4. Mapbox uses checkstyle to enforce good Java code standards, Make sure to read the [wiki entry](https://github.com/mapbox/mapbox-java/wiki/Setting-up-Mapbox-checkstyle) and setup. CI will fail if your PR contains any mistakes.
14+
1315
# Code of conduct
1416
Everyone is invited to participate in Mapbox’s open source projects and public discussions: we want to create a welcoming and friendly environment. Harassment of participants or other unethical and unprofessional behavior will not be tolerated in our spaces. The [Contributor Covenant](http://contributor-covenant.org) applies to all projects under the Mapbox organization and we ask that you please read [the full text](http://contributor-covenant.org/version/1/2/0/).
1517

libjava/lib/src/main/java/com/mapbox/services/commons/MapboxBuilder.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
*/
88
public abstract class MapboxBuilder {
99

10-
public abstract MapboxBuilder setAccessToken(String accessToken);
10+
public abstract MapboxBuilder setAccessToken(String accessToken);
1111

12-
public abstract String getAccessToken();
12+
public abstract String getAccessToken();
1313

14-
/**
15-
* Method to validate a Mapbox Access token.
16-
*
17-
* @param accessToken A string containing a Mapbox Access Token
18-
* @throws ServicesException Generic Exception for all things Mapbox.
19-
* @since 1.0.0
20-
*/
21-
protected void validateAccessToken(String accessToken) throws ServicesException {
22-
if (!MapboxUtils.isAccessTokenValid(accessToken)) {
23-
throw new ServicesException(
24-
"Using Mapbox Services requires setting a valid access token.");
25-
}
14+
/**
15+
* Method to validate a Mapbox Access token.
16+
*
17+
* @param accessToken A string containing a Mapbox Access Token
18+
* @throws ServicesException Generic Exception for all things Mapbox.
19+
* @since 1.0.0
20+
*/
21+
protected void validateAccessToken(String accessToken) throws ServicesException {
22+
if (!MapboxUtils.isAccessTokenValid(accessToken)) {
23+
throw new ServicesException(
24+
"Using Mapbox Services requires setting a valid access token.");
2625
}
26+
}
2727

28-
/**
29-
* The builder.
30-
*
31-
* @return {@link MapboxBuilder}
32-
* @throws ServicesException Generic Exception for all things Mapbox.
33-
* @since 1.0.0
34-
*/
35-
public abstract Object build() throws ServicesException;
28+
/**
29+
* The builder.
30+
*
31+
* @return {@link MapboxBuilder}
32+
* @throws ServicesException Generic Exception for all things Mapbox.
33+
* @since 1.0.0
34+
*/
35+
public abstract Object build() throws ServicesException;
3636

3737
}

libjava/lib/src/main/java/com/mapbox/services/commons/MapboxService.java

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,66 +20,66 @@
2020
*/
2121
public abstract class MapboxService<T> {
2222

23-
private boolean enableDebug = false;
23+
private boolean enableDebug = false;
2424

25-
public abstract Response<T> executeCall() throws IOException;
25+
public abstract Response<T> executeCall() throws IOException;
2626

27-
public abstract void enqueueCall(Callback<T> callback);
27+
public abstract void enqueueCall(Callback<T> callback);
2828

29-
public abstract void cancelCall();
29+
public abstract void cancelCall();
3030

31-
public abstract Call<T> cloneCall();
31+
public abstract Call<T> cloneCall();
3232

33-
public boolean isEnableDebug() {
34-
return enableDebug;
35-
}
33+
public boolean isEnableDebug() {
34+
return enableDebug;
35+
}
3636

37-
public void setEnableDebug(boolean enableDebug) {
38-
this.enableDebug = enableDebug;
39-
}
37+
public void setEnableDebug(boolean enableDebug) {
38+
this.enableDebug = enableDebug;
39+
}
4040

41-
/**
42-
* Used Internally.
43-
*
44-
* @return OkHttpClient
45-
* @since 1.0.0
46-
*/
47-
public OkHttpClient getOkHttpClient() {
48-
if (isEnableDebug()) {
49-
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
50-
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
51-
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
52-
httpClient.addInterceptor(logging);
53-
return httpClient.build();
54-
} else {
55-
return new OkHttpClient();
56-
}
41+
/**
42+
* Used Internally.
43+
*
44+
* @return OkHttpClient
45+
* @since 1.0.0
46+
*/
47+
public OkHttpClient getOkHttpClient() {
48+
if (isEnableDebug()) {
49+
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
50+
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
51+
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
52+
httpClient.addInterceptor(logging);
53+
return httpClient.build();
54+
} else {
55+
return new OkHttpClient();
5756
}
57+
}
5858

59-
/**
60-
* Computes a full user agent header of the form: MapboxJava/1.2.0 Mac OS X/10.11.5 (x86_64)
61-
*
62-
* @return {@link String}
63-
* @since 1.0.0
64-
*/
65-
public static String getHeaderUserAgent() {
66-
String osName;
67-
String osVersion;
68-
String osArch;
59+
/**
60+
* Computes a full user agent header of the form: MapboxJava/1.2.0 Mac OS X/10.11.5 (x86_64)
61+
*
62+
* @return {@link String}
63+
* @since 1.0.0
64+
*/
65+
public static String getHeaderUserAgent() {
66+
String osName;
67+
String osVersion;
68+
String osArch;
6969

70-
try {
71-
osName = System.getProperty("os.name");
72-
osVersion = System.getProperty("os.version");
73-
osArch = System.getProperty("os.arch");
74-
} catch (Exception e) {
75-
return Constants.HEADER_USER_AGENT;
76-
}
70+
try {
71+
osName = System.getProperty("os.name");
72+
osVersion = System.getProperty("os.version");
73+
osArch = System.getProperty("os.arch");
74+
} catch (Exception exception) {
75+
return Constants.HEADER_USER_AGENT;
76+
}
7777

78-
if (TextUtils.isEmpty(osName) || TextUtils.isEmpty(osVersion) || TextUtils.isEmpty(osArch)) {
79-
return Constants.HEADER_USER_AGENT;
80-
} else {
81-
String osInfo = String.format(Locale.US, "%s/%s (%s)", osName, osVersion, osArch);
82-
return String.format(Locale.US, "%s %s", Constants.HEADER_USER_AGENT, osInfo);
83-
}
78+
if (TextUtils.isEmpty(osName) || TextUtils.isEmpty(osVersion) || TextUtils.isEmpty(osArch)) {
79+
return Constants.HEADER_USER_AGENT;
80+
} else {
81+
String osInfo = String.format(Locale.US, "%s/%s (%s)", osName, osVersion, osArch);
82+
return String.format(Locale.US, "%s %s", Constants.HEADER_USER_AGENT, osInfo);
8483
}
84+
}
8585
}

libjava/lib/src/main/java/com/mapbox/services/commons/ServicesException.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
*/
77
public class ServicesException extends Exception {
88

9-
/**
10-
* A form of {@code Throwable} that indicates conditions that a reasonable application might
11-
* want to catch.
12-
*
13-
* @param message the detail message (which is saved for later retrieval by the
14-
* {@link #getMessage()} method).
15-
* @since 1.0.0
16-
*/
17-
public ServicesException(String message) {
18-
super(message);
19-
}
9+
/**
10+
* A form of {@code Throwable} that indicates conditions that a reasonable application might
11+
* want to catch.
12+
*
13+
* @param message the detail message (which is saved for later retrieval by the
14+
* {@link #getMessage()} method).
15+
* @since 1.0.0
16+
*/
17+
public ServicesException(String message) {
18+
super(message);
19+
}
2020
}

libjava/lib/src/main/java/com/mapbox/services/commons/geojson/BaseFeatureCollection.java

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,44 @@
1313
*/
1414
public class BaseFeatureCollection implements GeoJSON {
1515

16-
private final String type = "FeatureCollection";
16+
private final String type = "FeatureCollection";
1717

18-
/**
19-
* Should always be "FeatureCollection".
20-
*
21-
* @return String "FeatureCollection".
22-
* @since 1.0.0
23-
*/
24-
@Override
25-
public String getType() {
26-
return type;
27-
}
18+
/**
19+
* Should always be "FeatureCollection".
20+
*
21+
* @return String "FeatureCollection".
22+
* @since 1.0.0
23+
*/
24+
@Override
25+
public String getType() {
26+
return type;
27+
}
2828

29-
/**
30-
* Create a GeoJSON feature collection object from JSON.
31-
*
32-
* @param json String of JSON making up a feature collection.
33-
* @return {@link FeatureCollection} GeoJSON object.
34-
* @since 1.0.0
35-
*/
36-
public static FeatureCollection fromJson(String json) {
37-
GsonBuilder gson = new GsonBuilder();
38-
gson.registerTypeAdapter(Position.class, new PositionDeserializer());
39-
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer());
40-
return gson.create().fromJson(json, FeatureCollection.class);
41-
}
29+
/**
30+
* Create a GeoJSON feature collection object from JSON.
31+
*
32+
* @param json String of JSON making up a feature collection.
33+
* @return {@link FeatureCollection} GeoJSON object.
34+
* @since 1.0.0
35+
*/
36+
public static FeatureCollection fromJson(String json) {
37+
GsonBuilder gson = new GsonBuilder();
38+
gson.registerTypeAdapter(Position.class, new PositionDeserializer());
39+
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer());
40+
return gson.create().fromJson(json, FeatureCollection.class);
41+
}
4242

43-
/**
44-
* Convert feature collection into JSON.
45-
*
46-
* @return String containing feature collection JSON.
47-
* @since 1.0.0
48-
*/
49-
@Override
50-
public String toJson() {
51-
GsonBuilder gson = new GsonBuilder();
52-
gson.registerTypeAdapter(Position.class, new PositionSerializer());
53-
return gson.create().toJson(this);
54-
}
43+
/**
44+
* Convert feature collection into JSON.
45+
*
46+
* @return String containing feature collection JSON.
47+
* @since 1.0.0
48+
*/
49+
@Override
50+
public String toJson() {
51+
GsonBuilder gson = new GsonBuilder();
52+
gson.registerTypeAdapter(Position.class, new PositionSerializer());
53+
return gson.create().toJson(this);
54+
}
5555

5656
}

0 commit comments

Comments
 (0)