已结束状态的任务可以转换回未启动状态

This commit is contained in:
EnderByEndera
2024-04-24 14:41:03 +08:00
parent 6920482f75
commit 2ac0174a00

View File

@@ -1,11 +1,16 @@
package com.realtime.protection.server.task.status.states;
import com.realtime.protection.configuration.utils.enums.StateEnum;
import com.realtime.protection.server.command.CommandService;
import com.realtime.protection.server.task.TaskService;
import com.realtime.protection.server.task.status.StateHandler;
public class FinishedState implements State {
public class FinishedState extends StateHandler implements State {
@Override
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) {
return newState instanceof FinishedState;
return switch (StateEnum.getStateEnumByState(newState)) {
case PENDING, FINISHED -> true;
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
};
}
}