1919import java .io .File ;
2020import java .io .FileFilter ;
2121import java .io .FilenameFilter ;
22+ import java .util .ArrayList ;
2223import java .util .Date ;
24+ import java .util .List ;
2325
2426import org .apache .commons .io .IOCase ;
2527
@@ -136,6 +138,7 @@ public static IOFileFilter fileFileFilter() {
136138 * @param filter1 the first filter
137139 * @param filter2 the second filter
138140 * @return a filter that ANDs the two specified filters
141+ * @deprecated use {@link #and(IOFileFilter...)}
139142 */
140143 public static IOFileFilter andFileFilter (IOFileFilter filter1 , IOFileFilter filter2 ) {
141144 return new AndFileFilter (filter1 , filter2 );
@@ -147,11 +150,63 @@ public static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filt
147150 * @param filter1 the first filter
148151 * @param filter2 the second filter
149152 * @return a filter that ORs the two specified filters
153+ * @deprecated use {@link #or(IOFileFilter...)}
150154 */
151155 public static IOFileFilter orFileFilter (IOFileFilter filter1 , IOFileFilter filter2 ) {
152156 return new OrFileFilter (filter1 , filter2 );
153157 }
154158
159+ /**
160+ * Returns a filter that ANDs the specified filters.
161+ *
162+ * @param filters the IOFileFilters that will be ANDed together.
163+ * @return a filter that ANDs the specified filters
164+ *
165+ * @throws IllegalArgumentException if the filters are null or contain a
166+ * null value.
167+ * @since Commons IO 2.0
168+ */
169+ public static IOFileFilter and (IOFileFilter ... filters ) {
170+ return new AndFileFilter (toList (filters ));
171+ }
172+
173+ /**
174+ * Returns a filter that ORs the specified filters.
175+ *
176+ * @param filters the IOFileFilters that will be ORed together.
177+ * @return a filter that ORs the specified filters
178+ *
179+ * @throws IllegalArgumentException if the filters are null or contain a
180+ * null value.
181+ * @since Commons IO 2.0
182+ */
183+ public static IOFileFilter or (IOFileFilter ... filters ) {
184+ return new OrFileFilter (toList (filters ));
185+ }
186+
187+ /**
188+ * Create a List of file filters.
189+ *
190+ * @param filters The file filters
191+ * @return The list of file filters
192+ * @throws IllegalArgumentException if the filters are null or contain a
193+ * null value.
194+ * @since Commons IO 2.0
195+ */
196+ public static List <IOFileFilter > toList (IOFileFilter ... filters ) {
197+ if (filters == null ) {
198+ throw new IllegalArgumentException ("The filters must not be null" );
199+ }
200+ List <IOFileFilter > list = new ArrayList <IOFileFilter >(filters .length );
201+ for (int i = 0 ; i < filters .length ; i ++) {
202+ if (filters [i ] == null ) {
203+ throw new IllegalArgumentException ("The filter[" + i + "] is null" );
204+ }
205+ list .add (filters [i ]);
206+ }
207+ return list ;
208+ }
209+
155210 /**
156211 * Returns a filter that NOTs the specified filter.
157212 *
0 commit comments