Use varargs.
MODIFY
src/test/java/org/apache/commons/io/FileUtilsTestCase.java
src/test/java/org/apache/commons/io/FileUtilsTestCase.java
@@ -732,7 +732,7 @@ public void testCopyDirectoryFiltered() throws Exception {
final File childDir = new File(parentDir, "child");
createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir);
- final NameFileFilter filter = new NameFileFilter(new String[]{"parent", "child", "file3.txt"});
+ final NameFileFilter filter = new NameFileFilter("parent", "child", "file3.txt");
final File destDir = new File(temporaryFolder, "copydest");
FileUtils.copyDirectory(grandParentDir, destDir, filter);

MODIFY
src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
@@ -1089,38 +1089,38 @@ public void testIsExtensionArray() {
assertFalse(FilenameUtils.isExtension(null, (String[]) null));
assertFalse(FilenameUtils.isExtension("file.txt", (String[]) null));
assertTrue(FilenameUtils.isExtension("file", (String[]) null));
- assertFalse(FilenameUtils.isExtension("file.txt", new String[0]));
+ assertFalse(FilenameUtils.isExtension("file.txt"));
assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"txt"}));
assertFalse(FilenameUtils.isExtension("file.txt", new String[]{"rtf"}));
- assertTrue(FilenameUtils.isExtension("file", new String[]{"rtf", ""}));
- assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"rtf", "txt"}));
+ assertTrue(FilenameUtils.isExtension("file", "rtf", ""));
+ assertTrue(FilenameUtils.isExtension("file.txt", "rtf", "txt"));
assertFalse(FilenameUtils.isExtension("a/b/file.txt", (String[]) null));
- assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[0]));
+ assertFalse(FilenameUtils.isExtension("a/b/file.txt"));
assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"txt"}));
assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf"}));
- assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf", "txt"}));
+ assertTrue(FilenameUtils.isExtension("a/b/file.txt", "rtf", "txt"));
assertFalse(FilenameUtils.isExtension("a.b/file.txt", (String[]) null));
- assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[0]));
+ assertFalse(FilenameUtils.isExtension("a.b/file.txt"));
assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"txt"}));
assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf"}));
- assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf", "txt"}));
+ assertTrue(FilenameUtils.isExtension("a.b/file.txt", "rtf", "txt"));
assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (String[]) null));
- assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[0]));
+ assertFalse(FilenameUtils.isExtension("a\\b\\file.txt"));
assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"txt"}));
assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf"}));
- assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf", "txt"}));
+ assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", "rtf", "txt"));
assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (String[]) null));
- assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[0]));
+ assertFalse(FilenameUtils.isExtension("a.b\\file.txt"));
assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"txt"}));
assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf"}));
- assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf", "txt"}));
+ assertTrue(FilenameUtils.isExtension("a.b\\file.txt", "rtf", "txt"));
assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT"}));
- assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT", "RTF"}));
+ assertFalse(FilenameUtils.isExtension("a.b\\file.txt", "TXT", "RTF"));
}
@Test
@@ -1156,36 +1156,36 @@ public void testIsExtensionCollection() {
assertFalse(FilenameUtils.isExtension("file.txt", (Collection<String>) null));
assertTrue(FilenameUtils.isExtension("file", (Collection<String>) null));
assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<String>()));
- assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList(new String[]{"txt"}))));
- assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf"}))));
- assertTrue(FilenameUtils.isExtension("file", new ArrayList<>(Arrays.asList(new String[]{"rtf", ""}))));
- assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf", "txt"}))));
+ assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList("txt"))));
+ assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList("rtf"))));
+ assertTrue(FilenameUtils.isExtension("file", new ArrayList<>(Arrays.asList("rtf", ""))));
+ assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList<>(Arrays.asList("rtf", "txt"))));
assertFalse(FilenameUtils.isExtension("a/b/file.txt", (Collection<String>) null));
assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<String>()));
- assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"txt"}))));
- assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf"}))));
- assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf", "txt"}))));
+ assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList("txt"))));
+ assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList("rtf"))));
+ assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList<>(Arrays.asList("rtf", "txt"))));
assertFalse(FilenameUtils.isExtension("a.b/file.txt", (Collection<String>) null));
assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<String>()));
- assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"txt"}))));
- assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf"}))));
- assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf", "txt"}))));
+ assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList("txt"))));
+ assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList("rtf"))));
+ assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList<>(Arrays.asList("rtf", "txt"))));
assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (Collection<String>) null));
assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<String>()));
- assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"txt"}))));
- assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf"}))));
- assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf", "txt"}))));
+ assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList("txt"))));
+ assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList("rtf"))));
+ assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList<>(Arrays.asList("rtf", "txt"))));
assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (Collection<String>) null));
assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<String>()));
- assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"txt"}))));
- assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf"}))));
- assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"rtf", "txt"}))));
+ assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList("txt"))));
+ assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList("rtf"))));
+ assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList("rtf", "txt"))));
- assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"TXT"}))));
- assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList(new String[]{"TXT", "RTF"}))));
+ assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList("TXT"))));
+ assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList<>(Arrays.asList("TXT", "RTF"))));
}
}

MODIFY
src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
@BeforeEach
public void setUp() throws Exception {
comparator = new CompositeFileComparator(
- new AbstractFileComparator[] {
- (AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR,
- (AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR});
+ (AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR, (AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR);
reverse = new ReverseFileComparator(comparator);
lessFile = new File(dir, "xyz.txt");
equalFile1 = new File(dir, "foo.txt");

MODIFY
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
@@ -460,7 +460,7 @@ public void testDeprecatedWildcard() {
assertFiltering(filter, new File("openXY.123103").toPath(), false);
// assertFiltering(filter, new File("openAB.102504.old").toPath(), false);
- filter = new WildcardFilter(new String[] {"*.java", "*.class"});
+ filter = new WildcardFilter("*.java", "*.class");
assertFiltering(filter, new File("Test.java"), true);
assertFiltering(filter, new File("Test.class"), true);
assertFiltering(filter, new File("Test.jsp"), false);
@@ -1258,7 +1258,7 @@ public void testMakeSVNAware() throws Exception {
@Test
public void testNameFilter() {
- assertFooBarFileFiltering(new NameFileFilter(new String[] {"foo", "bar"}));
+ assertFooBarFileFiltering(new NameFileFilter("foo", "bar"));
}
@Test
@@ -1367,7 +1367,7 @@ public void testPathEqualsFilter() {
@Test
public void testPrefix() {
- IOFileFilter filter = new PrefixFileFilter(new String[] {"foo", "bar"});
+ IOFileFilter filter = new PrefixFileFilter("foo", "bar");
final File testFile = new File("test");
final Path testPath = testFile.toPath();
final File fredFile = new File("fred");
@@ -1597,7 +1597,7 @@ public void testSizeFilterOnPaths() throws Exception {
@Test
public void testSuffix() {
- IOFileFilter filter = new SuffixFileFilter(new String[] {"tes", "est"});
+ IOFileFilter filter = new SuffixFileFilter("tes", "est");
final File testFile = new File("test");
final Path testPath = testFile.toPath();
final File fredFile = new File("fred");
@@ -1769,7 +1769,7 @@ public void testWildcard() {
assertFiltering(filter, new File("log.txt").toPath(), true);
assertFiltering(filter, new File("log.TXT").toPath(), false);
- filter = new WildcardFileFilter(new String[] {"*.java", "*.class"});
+ filter = new WildcardFileFilter("*.java", "*.class");
assertFiltering(filter, new File("Test.java"), true);
assertFiltering(filter, new File("Test.class"), true);
assertFiltering(filter, new File("Test.jsp"), false);

Use varargs.