Start category usecase

This commit is contained in:
qvalentin 2022-04-01 17:07:46 +02:00
parent f003a9a5e2
commit 135c7e2ad9
Signed by: qvalentin
GPG Key ID: C979FA1EAFCABF1C
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,6 @@
package category;
public interface CategoryIdGenerator
{
CategoryId generateId();
}

View File

@ -0,0 +1,24 @@
package category;
import java.util.Set;
public class CategoryUseCase {
private final CategoryRepository categoryRepository;
private final CategoryIdGenerator categoryIdGenerator;
CategoryUseCase(final CategoryRepository categoryRepository, final CategoryIdGenerator idGenerator) {
this.categoryRepository = categoryRepository;
this.categoryIdGenerator = idGenerator;
}
public void addCategory(CategoryName name) {
var id = this.categoryIdGenerator.generateId();
this.categoryRepository.add(new Category(name, id));
}
public Set<Category> getCategories() {
return categoryRepository.getAll();
}
}