add adapter for cli for category
This commit is contained in:
parent
f5ce95e2dc
commit
cca611a1b0
26
1-Adapter/src/main/java/cli/category/CategoryCliAdapter.java
Normal file
26
1-Adapter/src/main/java/cli/category/CategoryCliAdapter.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package cli.category;
|
||||||
|
|
||||||
|
import category.CategoryName;
|
||||||
|
import category.CategoryUseCase;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CategoryCliAdapter {
|
||||||
|
|
||||||
|
private final CategoryUseCase categoryUseCase;
|
||||||
|
|
||||||
|
public CategoryCliAdapter(CategoryUseCase categoryUseCase) {
|
||||||
|
this.categoryUseCase = categoryUseCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCategory(String name) {
|
||||||
|
categoryUseCase.addCategory(new CategoryName(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getCategories() {
|
||||||
|
return categoryUseCase.getCategories().stream().map(Objects::toString).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in a new issue