Class ProductService


  • @Service
    public class ProductService
    extends Object
    This class handles all of the business logic for getting, putting, posting, and deleting items from the Product on behalf of the ProductService class, using methods from the ProductRepository interface.
    • Method Detail

      • save

        public Product save​(Product product)
        Saves the product into the database.
        Parameters:
        product - The Product to be saved.
        Returns:
        The Product that was saved.
      • get

        public Optional<Product> get​(long id)
        Returns a product by ID.
        Parameters:
        id - The Product ID.
        Returns:
        An Optional containing the matching Product.
      • getByName

        public Iterable<Product> getByName​(String nameFragment)
        Returns all Product objects with a name matching a keyword.
        Parameters:
        nameFragment - The search term keyword.
        Returns:
        An Iterable containing all Product objects that match the keyword.
      • getByProfileAndName

        public Iterable<Product> getByProfileAndName​(Profile profile,
                                                     String nameFragment)
        Returns all Product objects with a name matching a keyword, sold by a particular seller.
        Parameters:
        profile - The Profile of the seller.
        nameFragment - The search term keyword.
        Returns:
        An Iterable containing all Product objects that match the keyword that are sold by the seller Profile.
      • getAll

        public Iterable<Product> getAll()
        Returns every Product object in the database.
        Returns:
        An Iterable containing every Product object in the database.