Merge pull request #5316 from eugenp/BAEL-2086-v3

refactor dao
This commit is contained in:
Loredana Crusoveanu 2018-09-23 18:03:24 +03:00 committed by GitHub
commit 41b5cd81f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
public class TodoDao implements Dao<Todo> {
private List<Todo> todoList = new ArrayList<>();
@Override
public Optional<Todo> get(int id) {
return Optional.ofNullable(todoList.get(id));
@ -22,9 +22,9 @@ public class TodoDao implements Dao<Todo> {
@Override
public Collection<Todo> getAll() {
return Collections.unmodifiableCollection(todoList.stream()
return todoList.stream()
.filter(Objects::nonNull)
.collect(Collectors.toList()));
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
}
@Override