simplify switch case flow for DownloadMission

This commit is contained in:
Alex 2024-04-27 17:03:24 +07:00
parent 8e3449180f
commit c57f14bca5
No known key found for this signature in database
GPG Key ID: C9ABDE12115262C4
1 changed files with 9 additions and 17 deletions

View File

@ -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;
}
/**