@@ -50,30 +50,42 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
5050 private final IOCase caseSensitivity ;
5151
5252 /**
53- * Constructs a new case-sensitive name file filter for a single name .
53+ * Constructs a new case-sensitive name file filter for a list of names .
5454 *
55- * @param name the name to allow, must not be null
56- * @throws IllegalArgumentException if the name is null
55+ * @param names the names to allow, must not be null
56+ * @throws IllegalArgumentException if the name list is null
57+ * @throws ClassCastException if the list does not contain Strings
5758 */
58- public NameFileFilter (final String name ) {
59- this (name , null );
59+ public NameFileFilter (final List < String > names ) {
60+ this (names , null );
6061 }
6162
6263 /**
63- * Construct a new name file filter specifying case-sensitivity.
64+ * Constructs a new name file filter for a list of names specifying case-sensitivity.
6465 *
65- * @param name the name to allow, must not be null
66+ * @param names the names to allow, must not be null
6667 * @param caseSensitivity how to handle case sensitivity, null means case-sensitive
67- * @throws IllegalArgumentException if the name is null
68+ * @throws IllegalArgumentException if the name list is null
69+ * @throws ClassCastException if the list does not contain Strings
6870 */
69- public NameFileFilter (final String name , final IOCase caseSensitivity ) {
70- if (name == null ) {
71- throw new IllegalArgumentException ("The wildcard must not be null" );
71+ public NameFileFilter (final List < String > names , final IOCase caseSensitivity ) {
72+ if (names == null ) {
73+ throw new IllegalArgumentException ("The list of names must not be null" );
7274 }
73- this .names = new String [] { name } ;
75+ this .names = names . toArray ( EMPTY_STRING_ARRAY ) ;
7476 this .caseSensitivity = caseSensitivity == null ? IOCase .SENSITIVE : caseSensitivity ;
7577 }
7678
79+ /**
80+ * Constructs a new case-sensitive name file filter for a single name.
81+ *
82+ * @param name the name to allow, must not be null
83+ * @throws IllegalArgumentException if the name is null
84+ */
85+ public NameFileFilter (final String name ) {
86+ this (name , null );
87+ }
88+
7789 /**
7890 * Constructs a new case-sensitive name file filter for an array of names.
7991 * <p>
@@ -88,45 +100,33 @@ public NameFileFilter(final String... names) {
88100 }
89101
90102 /**
91- * Constructs a new name file filter for an array of names specifying case-sensitivity.
103+ * Construct a new name file filter specifying case-sensitivity.
92104 *
93- * @param names the names to allow, must not be null
105+ * @param name the name to allow, must not be null
94106 * @param caseSensitivity how to handle case sensitivity, null means case-sensitive
95- * @throws IllegalArgumentException if the names array is null
107+ * @throws IllegalArgumentException if the name is null
96108 */
97- public NameFileFilter (final String [] names , final IOCase caseSensitivity ) {
98- if (names == null ) {
99- throw new IllegalArgumentException ("The array of names must not be null" );
109+ public NameFileFilter (final String name , final IOCase caseSensitivity ) {
110+ if (name == null ) {
111+ throw new IllegalArgumentException ("The wildcard must not be null" );
100112 }
101- this .names = new String [names .length ];
102- System .arraycopy (names , 0 , this .names , 0 , names .length );
113+ this .names = new String [] {name };
103114 this .caseSensitivity = caseSensitivity == null ? IOCase .SENSITIVE : caseSensitivity ;
104115 }
105116
106117 /**
107- * Constructs a new case-sensitive name file filter for a list of names.
108- *
109- * @param names the names to allow, must not be null
110- * @throws IllegalArgumentException if the name list is null
111- * @throws ClassCastException if the list does not contain Strings
112- */
113- public NameFileFilter (final List <String > names ) {
114- this (names , null );
115- }
116-
117- /**
118- * Constructs a new name file filter for a list of names specifying case-sensitivity.
118+ * Constructs a new name file filter for an array of names specifying case-sensitivity.
119119 *
120120 * @param names the names to allow, must not be null
121121 * @param caseSensitivity how to handle case sensitivity, null means case-sensitive
122- * @throws IllegalArgumentException if the name list is null
123- * @throws ClassCastException if the list does not contain Strings
122+ * @throws IllegalArgumentException if the names array is null
124123 */
125- public NameFileFilter (final List < String > names , final IOCase caseSensitivity ) {
124+ public NameFileFilter (final String [] names , final IOCase caseSensitivity ) {
126125 if (names == null ) {
127- throw new IllegalArgumentException ("The list of names must not be null" );
126+ throw new IllegalArgumentException ("The array of names must not be null" );
128127 }
129- this .names = names .toArray (EMPTY_STRING_ARRAY );
128+ this .names = new String [names .length ];
129+ System .arraycopy (names , 0 , this .names , 0 , names .length );
130130 this .caseSensitivity = caseSensitivity == null ? IOCase .SENSITIVE : caseSensitivity ;
131131 }
132132
0 commit comments