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.
36 lines
716 B
36 lines
716 B
package com.crawler.command;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class CommandHistory {
|
|
private static CommandHistory instance;
|
|
private List<String> history;
|
|
|
|
private CommandHistory() {
|
|
history = new ArrayList<>();
|
|
}
|
|
|
|
public static CommandHistory getInstance() {
|
|
if (instance == null) {
|
|
instance = new CommandHistory();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
public void add(String command) {
|
|
history.add(command);
|
|
}
|
|
|
|
public List<String> getHistory() {
|
|
return new ArrayList<>(history);
|
|
}
|
|
|
|
public void clear() {
|
|
history.clear();
|
|
}
|
|
|
|
public int size() {
|
|
return history.size();
|
|
}
|
|
}
|