Class CatalogService

java.lang.Object
org.bookstore.catalog.service.CatalogService

public class CatalogService extends Object
The class CatalogService defines a service to manage the books of a bookstore.
  • Constructor Details

    • CatalogService

      public CatalogService()
  • Method Details

    • addBook

      public Book addBook(Book book) throws BookAlreadyExistsException
      Adds a book to the catalog.
      Parameters:
      book - the data of the book to be added
      Returns:
      the data of the added book
      Throws:
      BookAlreadyExistsException - if a book with the same ISBN already exists
    • findBook

      public Book findBook(String isbn) throws BookNotFoundException
      Finds a book in the catalog.
      Parameters:
      isbn - the ISBN of the book
      Returns:
      the data of the found book
      Throws:
      BookNotFoundException - if no book with the specified ISBN exists
    • searchBooks

      public List<Book> searchBooks(String keyword)
      Searches for books in the catalog.
      A book is included in the result if the keyword is contained in the title, authors or publisher field.
      Parameters:
      keyword - the keyword to search for
      Returns:
      the matching books
    • updateBook

      public Book updateBook(Book book) throws BookNotFoundException
      Updates a book in the catalog.
      Parameters:
      book - the new data of the book
      Returns:
      the data of the updated book
      Throws:
      BookNotFoundException - if no book with the corresponding ISBN exists