Use pattern matching switch cases

This commit is contained in:
AsamK 2023-10-17 19:52:35 +02:00
parent 80c1a6d2af
commit 8d55dfb66b
27 changed files with 395 additions and 380 deletions

View file

@ -223,13 +223,11 @@ public class SignalJsonRpcDispatcherHandler {
}
private Integer getSubscriptionId(final JsonNode request) {
if (request instanceof ArrayNode req) {
return req.get(0).asInt();
} else if (request instanceof ObjectNode req) {
return req.get("subscription").asInt();
} else {
return null;
}
return switch (request) {
case ArrayNode req -> req.get(0).asInt();
case ObjectNode req -> req.get("subscription").asInt();
case null, default -> null;
};
}
}
}