Skip to content

Commit ff8f29e

Browse files
author
github-actions
committed
Google Java Format
1 parent 36cf3cb commit ff8f29e

File tree

416 files changed

+58841
-50901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

416 files changed

+58841
-50901
lines changed

src/main/java/com/xero/api/ApiClient.java

Lines changed: 96 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -17,107 +17,111 @@
1717
import java.io.IOException;
1818
import java.io.OutputStream;
1919

20-
2120
public class ApiClient {
22-
private final String basePath;
23-
private final HttpRequestFactory httpRequestFactory;
24-
private final ObjectMapper objectMapper;
25-
private HttpTransport httpTransport = new NetHttpTransport();
26-
private int connectionTimeout = 20000;
27-
private int readTimeout = 20000;
28-
29-
private static final String defaultBasePath = "https://api.xero.com/api.xro/2.0";
30-
31-
// A reasonable default object mapper. Client can pass in a chosen ObjectMapper anyway, this is just for reasonable defaults.
32-
private static ObjectMapper createDefaultObjectMapper() {
33-
ObjectMapper objectMapper = new ObjectMapper()
21+
private final String basePath;
22+
private final HttpRequestFactory httpRequestFactory;
23+
private final ObjectMapper objectMapper;
24+
private HttpTransport httpTransport = new NetHttpTransport();
25+
private int connectionTimeout = 20000;
26+
private int readTimeout = 20000;
27+
28+
private static final String defaultBasePath = "https://api.xero.com/api.xro/2.0";
29+
30+
// A reasonable default object mapper. Client can pass in a chosen ObjectMapper anyway, this is
31+
// just for reasonable defaults.
32+
private static ObjectMapper createDefaultObjectMapper() {
33+
ObjectMapper objectMapper =
34+
new ObjectMapper()
3435
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
3536
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
3637
.setDateFormat(new RFC3339DateFormat())
3738
.setSerializationInclusion(Include.NON_EMPTY);
38-
objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
39-
40-
ThreeTenModule module = new ThreeTenModule();
41-
objectMapper.registerModule(module);
42-
return objectMapper;
43-
}
44-
45-
public ApiClient() {
46-
this(null, null, null, null,null);
47-
}
48-
49-
public ApiClient(
50-
String basePath,
51-
HttpTransport transport,
52-
HttpRequestInitializer initializer,
53-
ObjectMapper objectMapper,
54-
HttpRequestFactory reqFactory
55-
) {
56-
this.basePath = basePath == null ? defaultBasePath : (
57-
basePath.endsWith("/") ? basePath.substring(0, basePath.length() - 1) : basePath
58-
);
59-
if (transport != null) {
60-
this.httpTransport = transport;
61-
}
62-
this.httpRequestFactory = (reqFactory != null ? reqFactory : (transport == null ? Utils.getDefaultTransport() : transport).createRequestFactory(initializer) );
63-
this.objectMapper = (objectMapper == null ? createDefaultObjectMapper() : objectMapper);
64-
}
65-
66-
public HttpRequestFactory getHttpRequestFactory() {
67-
return httpRequestFactory;
68-
}
69-
70-
public int getConnectionTimeout() {
71-
return connectionTimeout;
72-
}
73-
74-
public void setConnectionTimeout(int connectionTimeout) {
75-
this.connectionTimeout = connectionTimeout;
76-
}
77-
78-
public int getReadTimeout() {
79-
return readTimeout;
80-
}
81-
82-
public void setReadTimeout(int readTimeout) {
83-
this.readTimeout = readTimeout;
84-
}
85-
86-
public HttpTransport getHttpTransport() {
87-
return httpTransport;
88-
}
89-
90-
public void setHttpTransport(HttpTransport transport) {
91-
this.httpTransport = transport;
39+
objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
40+
41+
ThreeTenModule module = new ThreeTenModule();
42+
objectMapper.registerModule(module);
43+
return objectMapper;
44+
}
45+
46+
public ApiClient() {
47+
this(null, null, null, null, null);
48+
}
49+
50+
public ApiClient(
51+
String basePath,
52+
HttpTransport transport,
53+
HttpRequestInitializer initializer,
54+
ObjectMapper objectMapper,
55+
HttpRequestFactory reqFactory) {
56+
this.basePath =
57+
basePath == null
58+
? defaultBasePath
59+
: (basePath.endsWith("/") ? basePath.substring(0, basePath.length() - 1) : basePath);
60+
if (transport != null) {
61+
this.httpTransport = transport;
9262
}
93-
94-
public String getBasePath() {
95-
return basePath;
63+
this.httpRequestFactory =
64+
(reqFactory != null
65+
? reqFactory
66+
: (transport == null ? Utils.getDefaultTransport() : transport)
67+
.createRequestFactory(initializer));
68+
this.objectMapper = (objectMapper == null ? createDefaultObjectMapper() : objectMapper);
69+
}
70+
71+
public HttpRequestFactory getHttpRequestFactory() {
72+
return httpRequestFactory;
73+
}
74+
75+
public int getConnectionTimeout() {
76+
return connectionTimeout;
77+
}
78+
79+
public void setConnectionTimeout(int connectionTimeout) {
80+
this.connectionTimeout = connectionTimeout;
81+
}
82+
83+
public int getReadTimeout() {
84+
return readTimeout;
85+
}
86+
87+
public void setReadTimeout(int readTimeout) {
88+
this.readTimeout = readTimeout;
89+
}
90+
91+
public HttpTransport getHttpTransport() {
92+
return httpTransport;
93+
}
94+
95+
public void setHttpTransport(HttpTransport transport) {
96+
this.httpTransport = transport;
97+
}
98+
99+
public String getBasePath() {
100+
return basePath;
101+
}
102+
103+
public ObjectMapper getObjectMapper() {
104+
return objectMapper;
105+
}
106+
107+
public class JacksonJsonHttpContent extends AbstractHttpContent {
108+
/* A POJO that can be serialized with a com.fasterxml Jackson ObjectMapper */
109+
private final Object data;
110+
111+
public JacksonJsonHttpContent(Object data) {
112+
super(Json.MEDIA_TYPE);
113+
this.data = data;
96114
}
97115

98-
public ObjectMapper getObjectMapper() {
99-
return objectMapper;
116+
@Override
117+
public void writeTo(OutputStream out) throws IOException {
118+
objectMapper.writeValue(out, data);
100119
}
120+
}
101121

102-
public class JacksonJsonHttpContent extends AbstractHttpContent {
103-
/* A POJO that can be serialized with a com.fasterxml Jackson ObjectMapper */
104-
private final Object data;
105-
106-
public JacksonJsonHttpContent(Object data) {
107-
super(Json.MEDIA_TYPE);
108-
this.data = data;
109-
}
122+
// Builder pattern to get API instances for this client.
110123

111-
@Override
112-
public void writeTo(OutputStream out) throws IOException {
113-
objectMapper.writeValue(out, data);
114-
}
115-
}
116-
117-
// Builder pattern to get API instances for this client.
118-
119-
public AccountingApi accountingApi() {
120-
return new AccountingApi(this);
121-
}
122-
124+
public AccountingApi accountingApi() {
125+
return new AccountingApi(this);
126+
}
123127
}

src/main/java/com/xero/api/RFC3339DateFormat.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020

2121
public class RFC3339DateFormat extends ISO8601DateFormat {
2222

23-
// Same as ISO8601DateFormat but serializing milliseconds.
24-
@Override
25-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
26-
String value = ISO8601Utils.format(date, true);
27-
toAppendTo.append(value);
28-
return toAppendTo;
29-
}
30-
31-
}
23+
// Same as ISO8601DateFormat but serializing milliseconds.
24+
@Override
25+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
26+
String value = ISO8601Utils.format(date, true);
27+
toAppendTo.append(value);
28+
return toAppendTo;
29+
}
30+
}

0 commit comments

Comments
 (0)