Changeset 19:3be646f02709 default default/master tip master

Moved javadoc to the repository interface
author unexist
date Thu, 15 Apr 2021 17:46:39 +0200
parents 47d10acd3463
children
files src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/TodoRepositoryImpl.java
diffstat 2 files changed, 52 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java	Sat Apr 10 16:10:43 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/domain/todo/TodoRepository.java	Thu Apr 15 17:46:39 2021 +0200
@@ -15,9 +15,56 @@
 import java.util.Optional;
 
 public interface TodoRepository {
+
+    /**
+     * Add {@link Todo} entry to list
+     *
+     * @param todo
+     *          {@link Todo} entry to add
+     * @return
+     *          Either {@code true} on success; otherwise {@code false}
+     **/
+
     boolean add(Todo todo);
+
+    /**
+     * Update {@link Todo} with given id
+     *
+     * @param todo
+     *          A {@link Todo} to update
+     * @return
+     *          Either {@code true} on success; otherwise {@code false}
+     **/
+
     boolean update(Todo todo);
+
+    /**
+     * Delete {@link Todo} with given id
+     *
+     * @param id
+     *          Id to delete
+     * @return
+     *          Either {@code true} on success; otherwise {@code false}
+     **/
+
     boolean deleteById(int id);
+
+    /**
+     * Get all {@link Todo} entries
+     *
+     * @return List of all stored {@link Todo}
+     **/
+
     List<Todo> getAll();
+
+    /**
+     * Find {@link Todo} by given id
+     *
+     * @param id
+     *          Id to find
+     * @return
+     *          A {@link Optional} with the result of the lookup
+     **/
+
     Optional<Todo> findById(int id);
 }
--- a/src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/TodoRepositoryImpl.java	Sat Apr 10 16:10:43 2021 +0200
+++ b/src/main/java/dev/unexist/showcase/todo/infrastructure/persistence/TodoRepositoryImpl.java	Thu Apr 15 17:46:39 2021 +0200
@@ -36,30 +36,14 @@
         this.list = new ArrayList<>();
     }
 
-    /**
-     * Add {@link Todo} entry to list
-     *
-     * @param todo
-     *          {@link Todo} entry to add
-     * @return
-     *          Either {@code true} on success; otherwise {@code false}
-     **/
-
+    @Override
     public boolean add(final Todo todo) {
         todo.setId(this.list.size() + 1);
 
         return this.list.add(todo);
     }
 
-    /**
-     * Update {@link Todo} with given id
-     *
-     * @param todo
-     *          A {@link Todo} to update
-     * @return
-     *          Either {@code true} on success; otherwise {@code false}
-     **/
-
+    @Override
     public boolean update(final Todo todo) {
         boolean ret = false;
 
@@ -74,15 +58,7 @@
         return ret;
     }
 
-    /**
-     * Delete {@link Todo} with given id
-     *
-     * @param id
-     *          Id to delete
-     * @return
-     *          Either {@code true} on success; otherwise {@code false}
-     **/
-
+    @Override
     public boolean deleteById(int id) {
         boolean ret = false;
 
@@ -97,25 +73,12 @@
         return ret;
     }
 
-    /**
-     * Get all {@link Todo} entries
-     *
-     * @return List of all stored {@link Todo}
-     **/
-
+    @Override
     public List<Todo> getAll() {
         return Collections.unmodifiableList(this.list);
     }
 
-    /**
-     * Find {@link Todo} by given id
-     *
-     * @param id
-     *          Id to find
-     * @return
-     *          A {@link Optional} with the result of the lookup
-     **/
-
+    @Override
     public Optional<Todo> findById(int id) {
         return this.list.stream()
                 .filter(t -> t.getId() == id)