refactor dao
This commit is contained in:
parent
1ee74058a2
commit
1a8eb6a0ef
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||||
public class TodoDao implements Dao<Todo> {
|
public class TodoDao implements Dao<Todo> {
|
||||||
|
|
||||||
private List<Todo> todoList = new ArrayList<>();
|
private List<Todo> todoList = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Todo> get(int id) {
|
public Optional<Todo> get(int id) {
|
||||||
return Optional.ofNullable(todoList.get(id));
|
return Optional.ofNullable(todoList.get(id));
|
||||||
|
@ -22,9 +22,9 @@ public class TodoDao implements Dao<Todo> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Todo> getAll() {
|
public Collection<Todo> getAll() {
|
||||||
return Collections.unmodifiableCollection(todoList.stream()
|
return todoList.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue