Class CategoryService
- java.lang.Object
-
- edu.cnm.deepdive.interviewprep.service.CategoryService
-
-
Constructor Summary
Constructors Constructor Description CategoryService(CategoryRepository categoryRepository)Constructor that instantiates a newCategoryservice object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CategorycreateCategory(Category category)Creates a newCategoryobject in the database.voiddelete(UUID externalKey)Deletes aCategoryobject identified by external key.Optional<Category>get(UUID externalKey)Gets the currentCategoryobject records from the database identified by id.List<Category>getCategories()Returns a list of allCategoryin the database.CategorysaveCategory(String name)Saves aCategoryobject to the database identified by name.CategoryupdateCategory(UUID externalKey, Category category)Updates aCategoryobject to the database for the current user.
-
-
-
Constructor Detail
-
CategoryService
public CategoryService(CategoryRepository categoryRepository)
Constructor that instantiates a newCategoryservice object.- Parameters:
categoryRepository- Category repository object.
-
-
Method Detail
-
get
public Optional<Category> get(UUID externalKey)
Gets the currentCategoryobject records from the database identified by id.- Parameters:
externalKey- Id in the form of a universally unique identifier.- Returns:
- An optional Category object.
-
getCategories
public List<Category> getCategories()
Returns a list of allCategoryin the database.- Returns:
- A list of all Category objects.
-
delete
public void delete(UUID externalKey)
Deletes aCategoryobject identified by external key.- Parameters:
externalKey- External key in the form of a universally unique identifier.
-
saveCategory
public Category saveCategory(String name)
Saves aCategoryobject to the database identified by name.- Parameters:
name- A category name in the form of a string.- Returns:
- A Category object.
-
createCategory
public Category createCategory(Category category)
Creates a newCategoryobject in the database.- Parameters:
category- A Category object.- Returns:
- A Category object.
-
-