Add one more helper method to FilterUtil

This commit is contained in:
Bradlee Speice 2014-05-05 00:59:16 -04:00
parent c2c5687d5b
commit 021dbe2b04

View File

@ -4,7 +4,9 @@ import org.crosswire.jsword.book.BookCategory;
import org.crosswire.jsword.book.BookFilter; import org.crosswire.jsword.book.BookFilter;
import org.crosswire.jsword.book.BookFilters; import org.crosswire.jsword.book.BookFilters;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
/** /**
* Module to help with some conversions between BookCategories and BookFilters * 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 static class InvalidFilterCategoryMappingException extends Exception {
public InvalidFilterCategoryMappingException(String message) { public InvalidFilterCategoryMappingException(String message) {
super(message); super(message);