upload
This commit is contained in:
@@ -2,7 +2,9 @@ package hhn.temp.project;
|
||||
|
||||
import hhn.temp.project.expections.TaskAlreadyExistsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TaskManager {
|
||||
@@ -24,4 +26,19 @@ public class TaskManager {
|
||||
taskMap.put(task.getTaskID(), task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public List<Task> getTaskList() {
|
||||
return new ArrayList<>(this.taskMap.values());
|
||||
}
|
||||
|
||||
public Task getTask(String name) {
|
||||
return taskMap.values().stream().filter(t -> t.getName().equals(name)).findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException("Wrong name"));
|
||||
}
|
||||
public Task getTask(int taskID) {
|
||||
if(!this.taskMap.containsKey(taskID)) {
|
||||
throw new IllegalArgumentException("Wrong id");
|
||||
}
|
||||
return this.taskMap.get(taskID);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user