| 
25 | 25 |  */  | 
26 | 26 | public class BookService {  | 
27 | 27 | 
 
  | 
28 |  | -	private static final Map<Integer, Book> books = new ConcurrentHashMap<>();  | 
29 |  | - | 
30 |  | -	static {  | 
31 |  | -		books.put(1, new Book("His Dark Materials", "Philip Pullman"));  | 
32 |  | -		books.put(2, new Book("Narnia", "C.S. Lewis"));  | 
33 |  | -		books.put(3, new Book("The Hobbit", "J.R.R. Tolkien"));  | 
34 |  | -		books.put(4, new Book("The Lord of The Rings", "J.R.R. Tolkien"));  | 
35 |  | -		books.put(5, new Book("The Silmarillion", "J.R.R. Tolkien"));  | 
36 |  | -	}  | 
 | 28 | +	private static final ConcurrentHashMap<Integer, Book> books = new ConcurrentHashMap<>(Map  | 
 | 29 | +		.of( // @formatter:off  | 
 | 30 | +		1, new Book("His Dark Materials", "Philip Pullman"),  | 
 | 31 | +		2, new Book("Narnia", "C.S. Lewis"),  | 
 | 32 | +		3, new Book("The Hobbit", "J.R.R. Tolkien"),  | 
 | 33 | +		4, new Book("The Lord of The Rings", "J.R.R. Tolkien"),  | 
 | 34 | +		5, new Book("The Silmarillion", "J.R.R. Tolkien"))); // @formatter:on  | 
37 | 35 | 
 
  | 
38 | 36 | 	public List<Book> getBooksByAuthor(Author author) {  | 
39 | 37 | 		return books.values().stream().filter(book -> author.name().equals(book.author())).toList();  | 
 | 
0 commit comments