You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/10/17 18:15:17 UTC
[commons-io] 04/04: Use default values instead of null to clarify
code, add Javadoc HTML closing tags,
refactor common code into a new private method.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 99596acb4b46663adb20f432cb9ed90c0ec47245
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Oct 17 14:15:07 2020 -0400
Use default values instead of null to clarify code, add Javadoc HTML
closing tags, refactor common code into a new private method.
---
.../org/apache/commons/io/filefilter/NameFileFilter.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java b/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java
index 9e50f58..e6df6df 100644
--- a/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java
+++ b/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java
@@ -97,7 +97,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
throw new IllegalArgumentException("The list of names must not be null");
}
this.names = names.toArray(EMPTY_STRING_ARRAY);
- this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ this.caseSensitivity = toIOCase(caseSensitivity);
}
/**
@@ -107,7 +107,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
* @throws IllegalArgumentException if the name is null
*/
public NameFileFilter(final String name) {
- this(name, null);
+ this(name, IOCase.SENSITIVE);
}
/**
@@ -115,12 +115,13 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
* <p>
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
+ * </p>
*
* @param names the names to allow, must not be null
* @throws IllegalArgumentException if the names array is null
*/
public NameFileFilter(final String... names) {
- this(names, null);
+ this(names, IOCase.SENSITIVE);
}
/**
@@ -135,7 +136,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
throw new IllegalArgumentException("The wildcard must not be null");
}
this.names = new String[] {name};
- this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ this.caseSensitivity = toIOCase(caseSensitivity);
}
/**
@@ -151,7 +152,7 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
}
this.names = new String[names.length];
System.arraycopy(names, 0, this.names, 0, names.length);
- this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ this.caseSensitivity = toIOCase(caseSensitivity);
}
/**
@@ -198,6 +199,10 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
return false;
}
+ private IOCase toIOCase(final IOCase caseSensitivity) {
+ return caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
+ }
+
/**
* Provide a String representation of this file filter.
*