Skip to content
This repository was archived by the owner on Jun 21, 2019. It is now read-only.

Commit 6f953f1

Browse files
author
Arne Augenstein
committed
Change line width to 120
1 parent 9f1043f commit 6f953f1

9 files changed

+32
-52
lines changed

spotless.eclipseformat.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
7373
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
7474
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
75-
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
75+
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
7676
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
7777
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
7878
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
@@ -307,7 +307,7 @@
307307
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
308308
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
309309
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
310-
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
310+
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
311311
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
312312
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
313313
</profile>

src/main/java/io/kamax/matrix/client/AMatrixHttpClient.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ protected URI getMediaPath(String action) {
129129
}
130130

131131
protected HttpEntity getJsonEntity(Object o) {
132-
return EntityBuilder.create().setText(gson.toJson(o))
133-
.setContentType(ContentType.APPLICATION_JSON).build();
132+
return EntityBuilder.create().setText(gson.toJson(o)).setContentType(ContentType.APPLICATION_JSON).build();
134133
}
135134

136135
}

src/main/java/io/kamax/matrix/client/MatrixClientContext.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public MatrixClientContext(_MatrixHomeserver hs, _MatrixID user, String token) {
3434
this(hs, user, token, false);
3535
}
3636

37-
public MatrixClientContext(_MatrixHomeserver hs, _MatrixID user, String token,
38-
boolean isVirtualUser) {
37+
public MatrixClientContext(_MatrixHomeserver hs, _MatrixID user, String token, boolean isVirtualUser) {
3938
this.hs = hs;
4039
this.user = user;
4140
this.token = token;

src/main/java/io/kamax/matrix/client/MatrixHttpContent.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ private synchronized void load() {
6868

6969
try {
7070
if (!StringUtils.equalsIgnoreCase("mxc", address.getScheme())) {
71-
log.error("{} is not a supported protocol for avatars, ignoring",
72-
address.getScheme());
71+
log.error("{} is not a supported protocol for avatars, ignoring", address.getScheme());
7372
} else {
7473
URI path = getMediaPath("/download/" + address.getHost() + address.getPath());
7574
try (CloseableHttpResponse res = client.execute(log(new HttpGet(path)))) {
@@ -78,13 +77,12 @@ private synchronized void load() {
7877
log.info("Media {} does not exist on the HS {}", address.toString(),
7978
getContext().getHs().getDomain());
8079
} else {
81-
Charset charset = ContentType.getOrDefault(res.getEntity())
82-
.getCharset();
80+
Charset charset = ContentType.getOrDefault(res.getEntity()).getCharset();
8381
String body = IOUtils.toString(res.getEntity().getContent(), charset);
8482

8583
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
86-
log.error("Couldn't get content data for {}: {} - {}",
87-
address.toString(), info.getErrcode(), info.getError());
84+
log.error("Couldn't get content data for {}: {} - {}", address.toString(),
85+
info.getErrcode(), info.getError());
8886
}
8987
} else {
9088
HttpEntity entity = res.getEntity();
@@ -93,20 +91,17 @@ private synchronized void load() {
9391
} else {
9492
Header contentType = entity.getContentType();
9593
if (contentType == null) {
96-
log.info(
97-
"No content type was given, unable to process avatar data");
94+
log.info("No content type was given, unable to process avatar data");
9895
} else {
9996
type = contentType.getValue();
10097
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
10198
entity.writeTo(outStream);
10299
data = outStream.toByteArray();
103100
isValid = true;
104101

105-
Header contentDisposition = res
106-
.getFirstHeader("Content-Disposition");
102+
Header contentDisposition = res.getFirstHeader("Content-Disposition");
107103
if (contentDisposition != null) {
108-
Matcher m = filenamePattern
109-
.matcher(contentDisposition.getValue());
104+
Matcher m = filenamePattern.matcher(contentDisposition.getValue());
110105
if (m.find()) {
111106
filename = m.group("filename");
112107
}

src/main/java/io/kamax/matrix/client/MatrixHttpRoom.java

+13-20
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ public Optional<String> getName() {
9292
log.warn("Request was rate limited", new Exception());
9393
}
9494
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
95-
throw new IOException("Couldn't get name for room " + roomId + " - "
96-
+ info.getErrcode() + ": " + info.getError());
95+
throw new IOException("Couldn't get name for room " + roomId + " - " + info.getErrcode() + ": "
96+
+ info.getError());
9797
}
9898

99-
return Optional
100-
.of(jsonParser.parse(body).getAsJsonObject().get("name").getAsString());
99+
return Optional.of(jsonParser.parse(body).getAsJsonObject().get("name").getAsString());
101100
}
102101
} catch (IOException e) {
103102
throw new MatrixClientRequestException(e);
@@ -124,12 +123,10 @@ public Optional<String> getTopic() {
124123
log.warn("Request was rate limited", new Exception());
125124
}
126125
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
127-
throw new MatrixClientRequestException(info,
128-
"Couldn't get topic for room " + roomId);
126+
throw new MatrixClientRequestException(info, "Couldn't get topic for room " + roomId);
129127
}
130128

131-
return Optional
132-
.of(jsonParser.parse(body).getAsJsonObject().get("topic").getAsString());
129+
return Optional.of(jsonParser.parse(body).getAsJsonObject().get("topic").getAsString());
133130
}
134131
} catch (IOException e) {
135132
throw new MatrixClientRequestException(e);
@@ -157,8 +154,7 @@ public void join() {
157154
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
158155

159156
if (res.getStatusLine().getStatusCode() == 403) {
160-
log.error("Failed to join room, we are not allowed: {} - {}", info.getErrcode(),
161-
info.getError());
157+
log.error("Failed to join room, we are not allowed: {} - {}", info.getErrcode(), info.getError());
162158
} else {
163159
throw new MatrixClientRequestException(info, "Error joining for " + getUser());
164160
}
@@ -195,8 +191,7 @@ public void leave() {
195191
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
196192

197193
if (res.getStatusLine().getStatusCode() == 403) {
198-
log.debug(
199-
"Failed to leave room, we are not allowed, most likely already left: {} - {}",
194+
log.debug("Failed to leave room, we are not allowed, most likely already left: {} - {}",
200195
info.getErrcode(), info.getError());
201196
} else {
202197
throw new MatrixClientRequestException(info,
@@ -211,8 +206,7 @@ public void leave() {
211206

212207
private void sendMessage(RoomMessageTextPutBody content) {
213208
try {
214-
URI path = getClientPath(
215-
"/rooms/{roomId}/send/m.room.message/" + System.currentTimeMillis());
209+
URI path = getClientPath("/rooms/{roomId}/send/m.room.message/" + System.currentTimeMillis());
216210
HttpPut req = new HttpPut(path);
217211
req.setEntity(getJsonEntity(content));
218212

@@ -232,8 +226,8 @@ private void sendMessage(RoomMessageTextPutBody content) {
232226
if (res.getStatusLine().getStatusCode() == 403) {
233227
log.error("Failed send message, we are not allowed: {}", info.getError());
234228
} else {
235-
throw new IOException("Error sending message for " + getUser() + " - "
236-
+ info.getErrcode() + ": " + info.getError());
229+
throw new IOException("Error sending message for " + getUser() + " - " + info.getErrcode()
230+
+ ": " + info.getError());
237231
}
238232
}
239233
}
@@ -285,12 +279,11 @@ public List<_MatrixID> getJoinedUsers() {
285279
log.warn("Request was rate limited", new Exception());
286280
}
287281
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
288-
throw new IOException("Couldn't list joined users in " + roomId + " - "
289-
+ info.getErrcode() + ": " + info.getError());
282+
throw new IOException("Couldn't list joined users in " + roomId + " - " + info.getErrcode() + ": "
283+
+ info.getError());
290284
}
291285

292-
JsonObject joinedUsers = jsonParser.parse(body).getAsJsonObject().get("joined")
293-
.getAsJsonObject();
286+
JsonObject joinedUsers = jsonParser.parse(body).getAsJsonObject().get("joined").getAsJsonObject();
294287
List<_MatrixID> ids = new ArrayList<>();
295288
for (Map.Entry<String, JsonElement> entry : joinedUsers.entrySet()) {
296289
ids.add(new MatrixID(entry.getKey()));

src/main/java/io/kamax/matrix/client/MatrixHttpUser.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public Optional<String> getName() {
7878
}
7979

8080
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
81-
log.error("Couldn't get the displayname of {}: {} - {}", mxId,
82-
info.getErrcode(), info.getError());
81+
log.error("Couldn't get the displayname of {}: {} - {}", mxId, info.getErrcode(), info.getError());
8382
return Optional.empty();
8483
}
8584

@@ -117,8 +116,7 @@ public Optional<_MatrixContent> getAvatar() {
117116
}
118117

119118
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
120-
log.error("Couldn't get the avatar_url of {}: {} - {}", mxId, info.getErrcode(),
121-
info.getError());
119+
log.error("Couldn't get the avatar_url of {}: {} - {}", mxId, info.getErrcode(), info.getError());
122120
return Optional.empty();
123121
}
124122

src/main/java/io/kamax/matrix/client/as/MatrixApplicationServiceClient.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
import java.net.URI;
4141
import java.nio.charset.Charset;
4242

43-
public class MatrixApplicationServiceClient extends MatrixHttpClient
44-
implements _MatrixApplicationServiceClient {
43+
public class MatrixApplicationServiceClient extends MatrixHttpClient implements _MatrixApplicationServiceClient {
4544

4645
private Logger log = LoggerFactory.getLogger(MatrixApplicationServiceClient.class);
4746

@@ -50,8 +49,8 @@ public MatrixApplicationServiceClient(_MatrixHomeserver hs, String token, String
5049
}
5150

5251
private MatrixHttpClient createClient(String localpart) {
53-
return new MatrixHttpClient(new MatrixClientContext(getHomeserver(), getMatrixId(localpart),
54-
getAccessToken(), true));
52+
return new MatrixHttpClient(
53+
new MatrixClientContext(getHomeserver(), getMatrixId(localpart), getAccessToken(), true));
5554
}
5655

5756
@Override
@@ -73,8 +72,7 @@ public _MatrixClient createUser(String localpart) {
7372
log.warn("User {} already exists, ignoring", localpart);
7473
} else {
7574
// TODO turn into dedicated exceptions, following the Spec distinct errors
76-
throw new MatrixClientRequestException(info,
77-
"Error creating the new user " + localpart);
75+
throw new MatrixClientRequestException(info, "Error creating the new user " + localpart);
7876
}
7977
}
8078
}

src/main/java/io/kamax/matrix/client/regular/MatrixHttpClient.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public void setDisplayName(String name) {
7070
Charset charset = ContentType.getOrDefault(res.getEntity()).getCharset();
7171
String body = IOUtils.toString(res.getEntity().getContent(), charset);
7272
MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
73-
throw new MatrixClientRequestException(info,
74-
"Error changing display name for " + getUser());
73+
throw new MatrixClientRequestException(info, "Error changing display name for " + getUser());
7574
}
7675
}
7776
} catch (IOException e) {

src/main/java/io/kamax/matrix/json/event/MatrixJsonRoomMembershipEvent.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929

3030
import java.util.Optional;
3131

32-
public class MatrixJsonRoomMembershipEvent extends MatrixJsonRoomEvent
33-
implements _RoomMembershipEvent {
32+
public class MatrixJsonRoomMembershipEvent extends MatrixJsonRoomEvent implements _RoomMembershipEvent {
3433

3534
private Content content;
3635
private _MatrixID invitee;

0 commit comments

Comments
 (0)