From 021dbe2b04731248c381515dda3d7c22f1917843 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Mon, 5 May 2014 00:59:16 -0400 Subject: [PATCH] Add one more helper method to FilterUtil --- .../jsword/org/crosswire/jsword/book/FilterUtil.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java b/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java index 752cc30..ea0bc0a 100644 --- a/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java +++ b/src/main/java/jsword/org/crosswire/jsword/book/FilterUtil.java @@ -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 applyFilter(List books, BookFilter f) { + List filtered = new ArrayList(); + 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);