Class CategoryService
- java.lang.Object
-
- edu.cnm.deepdive.interviewprep.service.CategoryService
-
-
Constructor Summary
Constructors Constructor Description CategoryService(CategoryRepository categoryRepository)
Constructor that instantiates a newCategory
service object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Category
createCategory(Category category)
Creates a newCategory
object in the database.void
delete(UUID externalKey)
Deletes aCategory
object identified by external key.Optional<Category>
get(UUID externalKey)
Gets the currentCategory
object records from the database identified by id.List<Category>
getCategories()
Returns a list of allCategory
in the database.Category
saveCategory(String name)
Saves aCategory
object to the database identified by name.Category
updateCategory(UUID externalKey, Category category)
Updates aCategory
object to the database for the current user.
-
-
-
Constructor Detail
-
CategoryService
public CategoryService(CategoryRepository categoryRepository)
Constructor that instantiates a newCategory
service object.- Parameters:
categoryRepository
- Category repository object.
-
-
Method Detail
-
get
public Optional<Category> get(UUID externalKey)
Gets the currentCategory
object 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 allCategory
in the database.- Returns:
- A list of all Category objects.
-
delete
public void delete(UUID externalKey)
Deletes aCategory
object identified by external key.- Parameters:
externalKey
- External key in the form of a universally unique identifier.
-
saveCategory
public Category saveCategory(String name)
Saves aCategory
object 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 newCategory
object in the database.- Parameters:
category
- A Category object.- Returns:
- A Category object.
-
-