Better boolean file filters.
MODIFY
src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java
src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java
@@ -86,4 +86,9 @@ public FileVisitResult accept(final Path file, final BasicFileAttributes attribu
return FileVisitResult.TERMINATE;
}
+ @Override
+ public IOFileFilter not() {
+ return TrueFileFilter.INSTANCE;
+ }
+
}

MODIFY
src/main/java/org/apache/commons/io/filefilter/IOFileFilter.java
src/main/java/org/apache/commons/io/filefilter/IOFileFilter.java
@@ -93,7 +93,7 @@ default AndFileFilter and(final IOFileFilter... fileFilter) {
* @return a new filter
* @since 2.9.0
*/
- default NotFileFilter not() {
+ default IOFileFilter not() {
return new NotFileFilter(this);
}

MODIFY
src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java
src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java
@@ -86,4 +86,9 @@ public FileVisitResult accept(final Path file, final BasicFileAttributes attribu
return FileVisitResult.CONTINUE;
}
+ @Override
+ public IOFileFilter not() {
+ return FalseFileFilter.INSTANCE;
+ }
+
}

MODIFY
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
@@ -524,6 +524,8 @@ public void testTrue() throws Exception {
assertFiltering(filter, (Path) null, true);
//
assertSame(TrueFileFilter.TRUE, TrueFileFilter.INSTANCE);
+ assertSame(FalseFileFilter.FALSE, TrueFileFilter.INSTANCE.not());
+ assertSame(FalseFileFilter.INSTANCE, TrueFileFilter.INSTANCE.not());
}
@Test
@@ -536,6 +538,8 @@ public void testFalse() throws Exception {
assertFiltering(filter, (File) null, false);
assertFiltering(filter, (Path) null, false);
assertSame(FalseFileFilter.FALSE, FalseFileFilter.INSTANCE);
+ assertSame(TrueFileFilter.TRUE, FalseFileFilter.INSTANCE.not());
+ assertSame(TrueFileFilter.INSTANCE, FalseFileFilter.INSTANCE.not());
}
@Test

Better boolean file filters.