Package org.bookstore.catalog.service
Class CatalogService
java.lang.Object
org.bookstore.catalog.service.CatalogService
The class CatalogService defines a service to manage the books of a bookstore.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a book to the catalog.Finds a book in the catalog.searchBooks(List<String> keywords) Searches for books in the catalog.
A book is included in the result if all keywords are contained in the title, authors or publisher of the book.updateBook(Book book) Updates a book in the catalog.
-
Constructor Details
-
CatalogService
public CatalogService()
-
-
Method Details
-
addBook
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
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
Searches for books in the catalog.
A book is included in the result if all keywords are contained in the title, authors or publisher of the book.- Parameters:
keywords- the keywords to search for- Returns:
- the matching books
-
updateBook
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
-