Class CategoryService


  • @Service
    public class CategoryService
    extends Object
    This class implements the high level persistence and business logic for the Category entity.
    • Constructor Detail

      • CategoryService

        public CategoryService​(CategoryRepository categoryRepository)
        Constructor that instantiates a new Category service object.
        Parameters:
        categoryRepository - Category repository object.
    • Method Detail

      • get

        public Optional<Category> get​(UUID externalKey)
        Gets the current Category 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 all Category in the database.
        Returns:
        A list of all Category objects.
      • delete

        public void delete​(UUID externalKey)
        Deletes a Category object identified by external key.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
      • saveCategory

        public Category saveCategory​(String name)
        Saves a Category 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 new Category object in the database.
        Parameters:
        category - A Category object.
        Returns:
        A Category object.
      • updateCategory

        public Category updateCategory​(UUID externalKey,
                                       Category category)
        Updates a Category object to the database for the current user.
        Parameters:
        externalKey - External key in the form of a universally unique identifier.
        category - A Category object.
        Returns:
        A Category object.