mirror of
https://github.com/MinimalBible/jsword-minimalbible
synced 2024-11-22 07:58:20 -05:00
Add one more helper method to FilterUtil
This commit is contained in:
parent
c2c5687d5b
commit
021dbe2b04
@ -4,7 +4,9 @@ import org.crosswire.jsword.book.BookCategory;
|
||||
import org.crosswire.jsword.book.BookFilter;
|
||||
import org.crosswire.jsword.book.BookFilters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Module to help with some conversions between BookCategories and BookFilters
|
||||
@ -43,6 +45,16 @@ public class FilterUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Book> applyFilter(List<Book> books, BookFilter f) {
|
||||
List<Book> filtered = new ArrayList<Book>();
|
||||
for (Book b: books) {
|
||||
if (f.test(b)) {
|
||||
filtered.add(f);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public static class InvalidFilterCategoryMappingException extends Exception {
|
||||
public InvalidFilterCategoryMappingException(String message) {
|
||||
super(message);
|
||||
|
Loading…
Reference in New Issue
Block a user