Start category usecase
This commit is contained in:
parent
f003a9a5e2
commit
135c7e2ad9
|
@ -0,0 +1,6 @@
|
|||
package category;
|
||||
|
||||
public interface CategoryIdGenerator
|
||||
{
|
||||
CategoryId generateId();
|
||||
}
|
24
2-Application/src/main/java/category/CategoryUseCase.java
Normal file
24
2-Application/src/main/java/category/CategoryUseCase.java
Normal 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();
|
||||
}
|
||||
}
|
Reference in a new issue