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
-
Method Summary
Modifier and TypeMethodDescriptionAdds a book to the catalog.Finds a book in the catalog.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.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 the keyword is contained in the title, authors or publisher field.- Parameters:
keyword
- the keyword 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
-