더북(TheBook)

코드 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();

 

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.