add adapter for cli for category

This commit is contained in:
qvalentin 2022-05-15 11:38:31 +02:00
parent f5ce95e2dc
commit cca611a1b0
Signed by: qvalentin
GPG Key ID: C979FA1EAFCABF1C
1 changed files with 26 additions and 0 deletions

View 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());
}
}