코드 6-9 BookRepositoryImpl.java
package com.springmvc.repository;
...
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
@Repository
public class BookRepositoryImpl implements BookRepository {
...
public List<Book> getBookListByCategory(String category) {
List<Book> booksByCategory = new ArrayList<Book>();
for (int i = 0; i < listOfBooks.size(); i++) {
Book book = listOfBooks.get(i);
if (category.equalsIgnoreCase(book.getCategory()))
booksByCategory.add(book);
}
return booksByCategory;
}
public Set<Book> getBookListByFilter(Map<String, List<String>> filter) {
Set<Book> booksByPublisher = new HashSet<Book>();
Set<Book> booksByCategory = new HashSet<Book>();
Set<String> booksByFilter = filter.keySet();