已结束状态的任务可以转换回未启动状态
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
package com.realtime.protection.server.task.status.states;
|
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.command.CommandService;
|
||||||
import com.realtime.protection.server.task.TaskService;
|
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
|
@Override
|
||||||
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) {
|
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));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user