Ejemplo n.º 1
0
 public List<Book> booksForAuthor(Author author) {
   final boolean isNull = Author.NULL.equals(author);
   final LinkedList<Book> filtered = new LinkedList<Book>();
   for (Book b : books()) {
     final List<Author> bookAuthors = b.authors();
     if (isNull && bookAuthors.isEmpty() || bookAuthors.contains(author)) {
       filtered.add(b);
     }
   }
   return filtered;
 }
Ejemplo n.º 2
0
 public List<Book> booksForSeriesAndAuthor(String series, Author author) {
   final boolean isNull = Author.NULL.equals(author);
   final LinkedList<Book> filtered = new LinkedList<Book>();
   for (Book b : books()) {
     final List<Author> bookAuthors = b.authors();
     final SeriesInfo info = b.getSeriesInfo();
     if (info != null
         && series.equals(info.Title)
         && (isNull && bookAuthors.isEmpty() || bookAuthors.contains(author))) {
       filtered.add(b);
     }
   }
   return filtered;
 }
Ejemplo n.º 3
0
 public List<String> titlesForAuthor(Author author, int limit) {
   if (limit <= 0) {
     return Collections.emptyList();
   }
   final ArrayList<String> titles = new ArrayList<String>(limit);
   final boolean isNull = Author.NULL.equals(author);
   synchronized (myBooksByFile) {
     for (Book b : myBooksByFile.values()) {
       if (isNull ? b.authors().isEmpty() : b.authors().contains(author)) {
         titles.add(b.getTitle());
         if (--limit == 0) {
           break;
         }
       }
     }
   }
   return titles;
 }
Ejemplo n.º 4
0
 public List<String> titlesForSeriesAndAuthor(String series, Author author, int limit) {
   if (limit <= 0) {
     return Collections.emptyList();
   }
   final boolean isNull = Author.NULL.equals(author);
   final ArrayList<String> titles = new ArrayList<String>(limit);
   synchronized (myBooksByFile) {
     for (Book b : myBooksByFile.values()) {
       final List<Author> bookAuthors = b.authors();
       final SeriesInfo info = b.getSeriesInfo();
       if (info != null
           && series.equals(info.Title)
           && (isNull && bookAuthors.isEmpty() || bookAuthors.contains(author))) {
         titles.add(b.getTitle());
         if (--limit == 0) {
           break;
         }
       }
     }
   }
   return titles;
 }