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 2021/05/28 16:30:12 UTC
[commons-io] branch master updated: Add and use Add
IOCase.isCaseSensitive(IOCase).
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
The following commit(s) were added to refs/heads/master by this push:
new 3bba1be Add and use Add IOCase.isCaseSensitive(IOCase).
3bba1be is described below
commit 3bba1beb8115dac754bafca7b45e424a7b35ba1c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 28 12:30:08 2021 -0400
Add and use Add IOCase.isCaseSensitive(IOCase).
---
src/changes/changes.xml | 7 +++++--
src/main/java/org/apache/commons/io/IOCase.java | 11 +++++++++++
.../org/apache/commons/io/filefilter/RegexFileFilter.java | 2 +-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 136e68b..b7d9e5a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -53,10 +53,13 @@ The <action> type attribute can be add,update,fix,remove.
</action>
<!-- ADD -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add RegexFileFilter.toString().
+ Add and use RegexFileFilter.toString().
</action>
<action dev="ggregory" type="add" due-to="Gary Gregory">
- Add RegexFileFilter.RegexFileFilter(Pattern, Function<Path>, String>)
+ Add and use RegexFileFilter.RegexFileFilter(Pattern, Function<Path>, String>)
+ </action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add and use IOCase.isCaseSensitive(IOCase).
</action>
</release>
<release version="2.9.0" date="2021-05-22" description="Java 8 required.">
diff --git a/src/main/java/org/apache/commons/io/IOCase.java b/src/main/java/org/apache/commons/io/IOCase.java
index b267f93..aba8075 100644
--- a/src/main/java/org/apache/commons/io/IOCase.java
+++ b/src/main/java/org/apache/commons/io/IOCase.java
@@ -64,6 +64,17 @@ public enum IOCase {
*/
SYSTEM("System", !FilenameUtils.isSystemWindows());
+ /**
+ * Tests for cases sensitivity in a null-safe manner.
+ *
+ * @param caseSensitivity an IOCase.
+ * @return true if the input is non-null and {@link #isCaseSensitive()}.
+ * @since 2.10.0
+ */
+ public static boolean isCaseSensitive(final IOCase caseSensitivity) {
+ return caseSensitivity != null && !caseSensitivity.isCaseSensitive();
+ }
+
/** Serialization version. */
private static final long serialVersionUID = -6343169151696340687L;
diff --git a/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java b/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java
index 327122e..2a5696e 100644
--- a/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java
+++ b/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java
@@ -91,7 +91,7 @@ public class RegexFileFilter extends AbstractFileFilter implements Serializable
* @return Pattern compilation flags.
*/
private static int toFlags(final IOCase caseSensitivity) {
- return caseSensitivity != null && !caseSensitivity.isCaseSensitive() ? Pattern.CASE_INSENSITIVE : 0;
+ return IOCase.isCaseSensitive(caseSensitivity) ? Pattern.CASE_INSENSITIVE : 0;
}
/** The regular expression pattern that will be used to match file names. */