코드 6-14 BookRepositoryImpl.java
package com.springmvc.repository;
...
@Repository
public class BookRepositoryImpl implements BookRepository {
...
public Set<Book> getBookListByFilter(Map<String, List<String>> filter) {
...
}
public Book getBookById(String bookId) {
Book bookInfo = null;
for (int i = 0; i < listOfBooks.size(); i++) {
Book book = listOfBooks.get(i);
if (book != null && book.getBookId() != null && book.getBookId().equals(bookId)) {
bookInfo = book;
break;
}
}
if (bookInfo == null)
throw new IllegalArgumentException("도서 ID가 " + bookId + "인 해당 도서를 찾을 수 없습니다.");
return bookInfo;
}
}