Skip to content

Commit dfae833

Browse files
committed
Fix Java formatting errors
A number of source files no longer matched the Google Java format. This commit applies the result of ./gradlew goJF With this commit, ./gradlew build finally succeeds again.
1 parent 7b7af1f commit dfae833

File tree

11 files changed

+105
-99
lines changed

11 files changed

+105
-99
lines changed

OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public JSONCommunicator(Radio radio) {
7777
super(radio);
7878
}
7979

80-
private static class ZonedDateTimeSerializer implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
80+
private static class ZonedDateTimeSerializer
81+
implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
8182

8283
@Override
8384
public JsonElement serialize(
@@ -87,8 +88,8 @@ public JsonElement serialize(
8788

8889
@Override
8990
public ZonedDateTime deserialize(
90-
JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
91-
throws JsonParseException {
91+
JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext)
92+
throws JsonParseException {
9293
return ZonedDateTime.parse(jsonElement.getAsJsonPrimitive().getAsString());
9394
}
9495
}

OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ of this software and associated documentation files (the "Software"), to deal
2727

2828
import eu.chargetime.ocpp.model.SessionInformation;
2929
import eu.chargetime.ocpp.wss.WssFactoryBuilder;
30-
import java.io.IOException;
3130
import java.net.ConnectException;
3231
import java.net.InetSocketAddress;
3332
import java.nio.charset.StandardCharsets;
@@ -82,9 +81,10 @@ public WebSocketListener(ISessionFactory sessionFactory, Draft... drafts) {
8281
public void open(String hostname, int port, ListenerEvents handler) {
8382
server =
8483
new WebSocketServer(
85-
new InetSocketAddress(hostname, port),
86-
configuration.getParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
87-
drafts) {
84+
new InetSocketAddress(hostname, port),
85+
configuration.getParameter(
86+
JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT),
87+
drafts) {
8888
@Override
8989
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
9090
logger.debug(
@@ -115,9 +115,9 @@ public void relay(String message) {
115115
String proxiedAddress = clientHandshake.getFieldValue(HTTP_HEADER_PROXIED_ADDRESS);
116116

117117
logger.debug(
118-
"New web-socket connection opened from address: {} proxied for: {}",
119-
webSocket.getRemoteSocketAddress(),
120-
proxiedAddress);
118+
"New web-socket connection opened from address: {} proxied for: {}",
119+
webSocket.getRemoteSocketAddress(),
120+
proxiedAddress);
121121

122122
SessionInformation information =
123123
new SessionInformation.Builder()
@@ -131,13 +131,14 @@ public void relay(String message) {
131131
}
132132

133133
@Override
134-
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket webSocket, Draft draft,
135-
ClientHandshake clientHandshake) throws InvalidDataException {
134+
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(
135+
WebSocket webSocket, Draft draft, ClientHandshake clientHandshake)
136+
throws InvalidDataException {
136137
SessionInformation information =
137-
new SessionInformation.Builder()
138-
.Identifier(clientHandshake.getResourceDescriptor())
139-
.InternetAddress(webSocket.getRemoteSocketAddress())
140-
.build();
138+
new SessionInformation.Builder()
139+
.Identifier(clientHandshake.getResourceDescriptor())
140+
.InternetAddress(webSocket.getRemoteSocketAddress())
141+
.build();
141142

142143
String username = null;
143144
byte[] password = null;
@@ -150,25 +151,26 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket web
150151
// split credentials on username and password
151152
for (int i = 0; i < credDecoded.length; i++) {
152153
if (credDecoded[i] == ':') {
153-
username = new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8);
154+
username =
155+
new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8);
154156
if (i + 1 < credDecoded.length) {
155157
password = Arrays.copyOfRange(credDecoded, i + 1, credDecoded.length);
156158
}
157159
break;
158160
}
159161
}
160162
}
161-
if (password == null || password.length < OCPPJ_CP_MIN_PASSWORD_LENGTH || password.length > OCPPJ_CP_MAX_PASSWORD_LENGTH)
163+
if (password == null
164+
|| password.length < OCPPJ_CP_MIN_PASSWORD_LENGTH
165+
|| password.length > OCPPJ_CP_MAX_PASSWORD_LENGTH)
162166
throw new InvalidDataException(401, "Invalid password length");
163167
}
164168

165169
try {
166170
handler.authenticateSession(information, username, password);
167-
}
168-
catch (AuthenticationException e) {
171+
} catch (AuthenticationException e) {
169172
throw new InvalidDataException(e.getErrorCode(), e.getMessage());
170-
}
171-
catch (Exception e) {
173+
} catch (Exception e) {
172174
throw new InvalidDataException(401, e.getMessage());
173175
}
174176
return super.onWebsocketHandshakeReceivedAsServer(webSocket, draft, clientHandshake);

ocpp-common/src/main/java/eu/chargetime/ocpp/AsyncPromiseFulfillerDecorator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static void setExecutor(ExecutorService newExecutor) {
4343

4444
@Override
4545
public void fulfill(
46-
CompletableFuture<Confirmation> promise, SessionEvents eventHandler, Request request) {
47-
executor.submit(() -> promiseFulfiller.fulfill(promise, eventHandler, request));
46+
CompletableFuture<Confirmation> promise, SessionEvents eventHandler, Request request) {
47+
executor.submit(() -> promiseFulfiller.fulfill(promise, eventHandler, request));
4848
}
4949

5050
public AsyncPromiseFulfillerDecorator(PromiseFulfiller promiseFulfiller) {

ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ public CompletableFuture<Confirmation> send(Request request)
163163
}
164164

165165
public UUID getSessionId() {
166-
return this.session.getSessionId();
166+
return this.session.getSessionId();
167167
}
168168
}

ocpp-common/src/main/java/eu/chargetime/ocpp/ListenerEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.model.SessionInformation;
2929

3030
public interface ListenerEvents {
31-
void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException;
31+
void authenticateSession(SessionInformation information, String username, byte[] password)
32+
throws AuthenticationException;
33+
3234
void newSession(ISession session, SessionInformation information);
3335
}

ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java

Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.feature.Feature;
2929
import eu.chargetime.ocpp.model.Confirmation;
3030
import eu.chargetime.ocpp.model.Request;
31+
import eu.chargetime.ocpp.model.SessionInformation;
3132
import java.util.Map;
3233
import java.util.Optional;
3334
import java.util.UUID;
3435
import java.util.concurrent.CompletableFuture;
3536
import java.util.concurrent.ConcurrentHashMap;
36-
37-
import eu.chargetime.ocpp.model.SessionInformation;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
4039

@@ -83,76 +82,80 @@ public void open(String hostname, int port, ServerEvents serverEvents) {
8382
new ListenerEvents() {
8483

8584
@Override
86-
public void authenticateSession(SessionInformation information, String username, byte[] password) throws AuthenticationException {
85+
public void authenticateSession(
86+
SessionInformation information, String username, byte[] password)
87+
throws AuthenticationException {
8788
serverEvents.authenticateSession(information, username, password);
8889
}
8990

9091
@Override
9192
public void newSession(ISession session, SessionInformation information) {
9293
session.accept(
93-
new SessionEvents() {
94-
@Override
95-
public void handleConfirmation(String uniqueId, Confirmation confirmation) {
96-
97-
Optional<CompletableFuture<Confirmation>> promiseOptional =
98-
promiseRepository.getPromise(uniqueId);
99-
if (promiseOptional.isPresent()) {
100-
promiseOptional.get().complete(confirmation);
101-
promiseRepository.removePromise(uniqueId);
102-
} else {
103-
logger.debug("Promise not found for confirmation {}", confirmation);
104-
}
105-
}
106-
107-
@Override
108-
public Confirmation handleRequest(Request request)
109-
throws UnsupportedFeatureException {
110-
Optional<Feature> featureOptional = featureRepository.findFeature(request);
111-
if (featureOptional.isPresent()) {
112-
Optional<UUID> sessionIdOptional = getSessionID(session);
113-
if (sessionIdOptional.isPresent()) {
114-
return featureOptional.get().handleRequest(sessionIdOptional.get(), request);
115-
} else {
116-
logger.error(
117-
"Unable to handle request ({}), the active session was not found.",
118-
request);
119-
throw new IllegalStateException("Active session not found");
120-
}
121-
} else {
122-
throw new UnsupportedFeatureException();
123-
}
94+
new SessionEvents() {
95+
@Override
96+
public void handleConfirmation(String uniqueId, Confirmation confirmation) {
97+
98+
Optional<CompletableFuture<Confirmation>> promiseOptional =
99+
promiseRepository.getPromise(uniqueId);
100+
if (promiseOptional.isPresent()) {
101+
promiseOptional.get().complete(confirmation);
102+
promiseRepository.removePromise(uniqueId);
103+
} else {
104+
logger.debug("Promise not found for confirmation {}", confirmation);
105+
}
106+
}
107+
108+
@Override
109+
public Confirmation handleRequest(Request request)
110+
throws UnsupportedFeatureException {
111+
Optional<Feature> featureOptional = featureRepository.findFeature(request);
112+
if (featureOptional.isPresent()) {
113+
Optional<UUID> sessionIdOptional = getSessionID(session);
114+
if (sessionIdOptional.isPresent()) {
115+
return featureOptional
116+
.get()
117+
.handleRequest(sessionIdOptional.get(), request);
118+
} else {
119+
logger.error(
120+
"Unable to handle request ({}), the active session was not found.",
121+
request);
122+
throw new IllegalStateException("Active session not found");
124123
}
125-
126-
@Override
127-
public void handleError(
128-
String uniqueId, String errorCode, String errorDescription, Object payload) {
129-
Optional<CompletableFuture<Confirmation>> promiseOptional =
130-
promiseRepository.getPromise(uniqueId);
131-
if (promiseOptional.isPresent()) {
132-
promiseOptional
133-
.get()
134-
.completeExceptionally(
135-
new CallErrorException(errorCode, errorDescription, payload));
136-
promiseRepository.removePromise(uniqueId);
137-
} else {
138-
logger.debug("Promise not found for error {}", errorDescription);
139-
}
140-
}
141-
142-
@Override
143-
public void handleConnectionClosed() {
144-
Optional<UUID> sessionIdOptional = getSessionID(session);
145-
if (sessionIdOptional.isPresent()) {
146-
serverEvents.lostSession(sessionIdOptional.get());
147-
sessions.remove(sessionIdOptional.get());
148-
} else {
149-
logger.warn("Active session not found");
150-
}
151-
}
152-
153-
@Override
154-
public void handleConnectionOpened() {}
155-
});
124+
} else {
125+
throw new UnsupportedFeatureException();
126+
}
127+
}
128+
129+
@Override
130+
public void handleError(
131+
String uniqueId, String errorCode, String errorDescription, Object payload) {
132+
Optional<CompletableFuture<Confirmation>> promiseOptional =
133+
promiseRepository.getPromise(uniqueId);
134+
if (promiseOptional.isPresent()) {
135+
promiseOptional
136+
.get()
137+
.completeExceptionally(
138+
new CallErrorException(errorCode, errorDescription, payload));
139+
promiseRepository.removePromise(uniqueId);
140+
} else {
141+
logger.debug("Promise not found for error {}", errorDescription);
142+
}
143+
}
144+
145+
@Override
146+
public void handleConnectionClosed() {
147+
Optional<UUID> sessionIdOptional = getSessionID(session);
148+
if (sessionIdOptional.isPresent()) {
149+
serverEvents.lostSession(sessionIdOptional.get());
150+
sessions.remove(sessionIdOptional.get());
151+
} else {
152+
logger.warn("Active session not found");
153+
}
154+
}
155+
156+
@Override
157+
public void handleConnectionOpened() {}
158+
});
156159

157160
sessions.put(session.getSessionId(), session);
158161

ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ public FirmwareStatusNotificationConfirmation handleFirmwareStatusNotificationRe
163163
public ServerEvents generateServerEventsHandler() {
164164
return new ServerEvents() {
165165
@Override
166-
public void authenticateSession(SessionInformation information, String username, byte[] password) {
167-
}
166+
public void authenticateSession(
167+
SessionInformation information, String username, byte[] password) {}
168168

169169
@Override
170170
public void newSession(UUID sessionIndex, SessionInformation information) {

ocpp-v1_6/src/main/java/eu/chargetime/ocpp/IClientAPI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.feature.profile.Profile;
2929
import eu.chargetime.ocpp.model.Confirmation;
3030
import eu.chargetime.ocpp.model.Request;
31-
3231
import java.util.UUID;
3332
import java.util.concurrent.CompletionStage;
3433

ocpp-v2_0-test/src/main/java/eu/chargetime/ocpp/test/FakeCentralSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void started() throws Exception {
7272
port,
7373
new ServerEvents() {
7474
@Override
75-
public void authenticateSession(SessionInformation information, String username, byte[] password) {
76-
}
75+
public void authenticateSession(
76+
SessionInformation information, String username, byte[] password) {}
7777

7878
@Override
7979
public void newSession(UUID sessionIndex, SessionInformation information) {

ocpp-v2_0/src/main/java/eu/chargetime/ocpp/IClientAPI.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ of this software and associated documentation files (the "Software"), to deal
2828
import eu.chargetime.ocpp.feature.Feature;
2929
import eu.chargetime.ocpp.model.Confirmation;
3030
import eu.chargetime.ocpp.model.Request;
31-
3231
import java.util.UUID;
3332
import java.util.concurrent.CompletionStage;
3433

0 commit comments

Comments
 (0)