Skip to content

Commit deb092b

Browse files
author
Gary Gregory
committed
Refactor null-checks.
1 parent 948345e commit deb092b

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

src/main/java/org/apache/commons/io/filefilter/PrefixFileFilter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ public PrefixFileFilter(final String... prefixes) {
133133
* @since 1.4
134134
*/
135135
public PrefixFileFilter(final String prefix, final IOCase ioCase) {
136-
if (prefix == null) {
137-
throw new IllegalArgumentException("The prefix must not be null");
138-
}
136+
requireNonNull(prefix, "prefix");
139137
this.prefixes = new String[] {prefix};
140138
this.isCase = IOCase.value(ioCase, IOCase.SENSITIVE);
141139
}
@@ -150,9 +148,7 @@ public PrefixFileFilter(final String prefix, final IOCase ioCase) {
150148
* @since 1.4
151149
*/
152150
public PrefixFileFilter(final String[] prefixes, final IOCase ioCase) {
153-
if (prefixes == null) {
154-
throw new IllegalArgumentException("The array of prefixes must not be null");
155-
}
151+
requireNonNull(prefixes, "prefixes");
156152
this.prefixes = prefixes.clone();
157153
this.isCase = IOCase.value(ioCase, IOCase.SENSITIVE);
158154
}

src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ public RegexFileFilter(final Pattern pattern) {
117117
* @since 2.10.0
118118
*/
119119
public RegexFileFilter(final Pattern pattern, final Function<Path, String> pathToString) {
120-
if (pattern == null) {
121-
throw new IllegalArgumentException("Pattern is missing");
122-
}
120+
requireNonNull(pattern, "pattern");
123121
this.pattern = pattern;
124122
this.pathToString = pathToString;
125123
}

src/main/java/org/apache/commons/io/filefilter/SuffixFileFilter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ public SuffixFileFilter(final String... suffixes) {
135135
* @since 1.4
136136
*/
137137
public SuffixFileFilter(final String suffix, final IOCase ioCase) {
138-
if (suffix == null) {
139-
throw new IllegalArgumentException("The suffix must not be null");
140-
}
138+
requireNonNull(suffix, "suffix");
141139
this.suffixes = new String[] {suffix};
142140
this.ioCase = IOCase.value(ioCase, IOCase.SENSITIVE);
143141
}
@@ -152,9 +150,7 @@ public SuffixFileFilter(final String suffix, final IOCase ioCase) {
152150
* @since 1.4
153151
*/
154152
public SuffixFileFilter(final String[] suffixes, final IOCase ioCase) {
155-
if (suffixes == null) {
156-
throw new IllegalArgumentException("The array of suffixes must not be null");
157-
}
153+
requireNonNull(suffixes, "suffixes");
158154
this.suffixes = suffixes.clone();
159155
this.ioCase = IOCase.value(ioCase, IOCase.SENSITIVE);
160156
}

0 commit comments

Comments
 (0)