Merge pull request 'Добавлен метод has для проверки существования задачи в InMemoryTaskRepository и TaskService.' (#32) from feature/service/has-with-id into dev
Reviewed-on: #32
This commit is contained in:
commit
644709a3f0
@ -10,6 +10,10 @@ public class TodoApp {
|
|||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
var service = new TaskService(new InMemoryTaskRepository());
|
var service = new TaskService(new InMemoryTaskRepository());
|
||||||
var cli = new CliEngine(service);
|
var cli = new CliEngine(service);
|
||||||
|
|
||||||
|
// service.create("test has-id");
|
||||||
|
// System.out.println(service.has(2));
|
||||||
|
|
||||||
cli.start();
|
cli.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,4 +30,8 @@ public class InMemoryTaskRepository implements TaskRepository {
|
|||||||
public void delete(int id) {
|
public void delete(int id) {
|
||||||
storage.remove(id);
|
storage.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean has(int id) {
|
||||||
|
return storage.containsKey(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,6 @@ public interface TaskRepository {
|
|||||||
List<Task> findAll();
|
List<Task> findAll();
|
||||||
|
|
||||||
void delete(int id);
|
void delete(int id);
|
||||||
|
|
||||||
|
boolean has(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,4 +38,8 @@ public class TaskService {
|
|||||||
public void remove(int id) {
|
public void remove(int id) {
|
||||||
repo.delete(id);
|
repo.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean has(int id) {
|
||||||
|
return repo.has(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user