From 07c694f02cdedf9b4fc230e8eba0e046379366f8 Mon Sep 17 00:00:00 2001 From: Yeikel Date: Sun, 15 Dec 2024 15:30:33 -0500 Subject: [PATCH] BE: Chore: use enhanced switch (#702) --- .../ui/service/KafkaConnectService.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/io/kafbat/ui/service/KafkaConnectService.java b/api/src/main/java/io/kafbat/ui/service/KafkaConnectService.java index d72580fe2..815069d07 100644 --- a/api/src/main/java/io/kafbat/ui/service/KafkaConnectService.java +++ b/api/src/main/java/io/kafbat/ui/service/KafkaConnectService.java @@ -207,22 +207,13 @@ public Mono deleteConnector( public Mono updateConnectorState(KafkaCluster cluster, String connectName, String connectorName, ConnectorActionDTO action) { return api(cluster, connectName) - .mono(client -> { - switch (action) { - case RESTART: - return client.restartConnector(connectorName, false, false); - case RESTART_ALL_TASKS: - return restartTasks(cluster, connectName, connectorName, task -> true); - case RESTART_FAILED_TASKS: - return restartTasks(cluster, connectName, connectorName, - t -> t.getStatus().getState() == ConnectorTaskStatusDTO.FAILED); - case PAUSE: - return client.pauseConnector(connectorName); - case RESUME: - return client.resumeConnector(connectorName); - default: - throw new IllegalStateException("Unexpected value: " + action); - } + .mono(client -> switch (action) { + case RESTART -> client.restartConnector(connectorName, false, false); + case RESTART_ALL_TASKS -> restartTasks(cluster, connectName, connectorName, task -> true); + case RESTART_FAILED_TASKS -> restartTasks(cluster, connectName, connectorName, + t -> t.getStatus().getState() == ConnectorTaskStatusDTO.FAILED); + case PAUSE -> client.pauseConnector(connectorName); + case RESUME -> client.resumeConnector(connectorName); }); }