You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
737 B
27 lines
737 B
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 命令历史记录类(MVC-控制层辅助)
|
|
*/
|
|
public class HistoryCommand {
|
|
// 私有化List,避免外部直接修改
|
|
private static final List<String> commandList = new ArrayList<>();
|
|
|
|
// 新增命令记录
|
|
public static void addCommand(String command) {
|
|
if (command != null && !command.trim().isEmpty()) {
|
|
commandList.add(command);
|
|
}
|
|
}
|
|
|
|
// 获取所有命令记录(返回副本,避免外部修改原集合)
|
|
public static List<String> getCommandList() {
|
|
return new ArrayList<>(commandList);
|
|
}
|
|
|
|
// 清空命令记录
|
|
public static void clearHistory() {
|
|
commandList.clear();
|
|
}
|
|
}
|