From c57f14bca5f5f2ad1c94859290b4c888235c5d57 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 27 Apr 2024 17:03:24 +0700 Subject: [PATCH] simplify switch case flow for DownloadMission --- .../us/shandian/giga/get/DownloadMission.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/us/shandian/giga/get/DownloadMission.java b/app/src/main/java/us/shandian/giga/get/DownloadMission.java index 04930b002..f58f73acb 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadMission.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadMission.java @@ -396,17 +396,11 @@ public class DownloadMission extends Mission { } private void notifyPostProcessing(int state) { - String action; - switch (state) { - case 1: - action = "Running"; - break; - case 2: - action = "Completed"; - break; - default: - action = "Failed"; - } + String action = switch (state) { + case 1 -> "Running"; + case 2 -> "Completed"; + default -> "Failed"; + }; Log.d(TAG, action + " postprocessing on " + storage.getName()); @@ -590,13 +584,11 @@ public class DownloadMission extends Mission { * @return {@code true} if this mission is unrecoverable */ public boolean isPsFailed() { - switch (errCode) { - case ERROR_POSTPROCESSING: - case ERROR_POSTPROCESSING_STOPPED: - return psAlgorithm.worksOnSameFile; - } + return switch (errCode) { + case ERROR_POSTPROCESSING, ERROR_POSTPROCESSING_STOPPED -> psAlgorithm.worksOnSameFile; + default -> false; + }; - return false; } /**