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 3f66ba69e Internal refactoring 3f66ba69e is described below commit 3f66ba69e6a0a8baa5402c5f3ca6e8ab0fc8ee1d Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Jan 29 18:29:41 2024 -0500 Internal refactoring --- .../commons/io/monitor/FileAlterationObserver.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java index a99368f7f..e862f36ee 100644 --- a/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java +++ b/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java @@ -131,6 +131,17 @@ public class FileAlterationObserver implements Serializable { private static final long serialVersionUID = 1185122225658782848L; + private static Comparator<File> toComparator(final IOCase ioCase) { + switch (IOCase.value(ioCase, IOCase.SYSTEM)) { + case SYSTEM: + return NameFileComparator.NAME_SYSTEM_COMPARATOR; + case INSENSITIVE: + return NameFileComparator.NAME_INSENSITIVE_COMPARATOR; + default: + return NameFileComparator.NAME_COMPARATOR; + } + } + /** * List of listeners. */ @@ -187,23 +198,25 @@ public class FileAlterationObserver implements Serializable { * * @param rootEntry the root directory to observe. * @param fileFilter The file filter or null if none. - * @param ioCase what case sensitivity to use comparing file names, null means system sensitive. + * @param comparator how to compare files. */ - protected FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter, final IOCase ioCase) { + private FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter, final Comparator<File> comparator) { Objects.requireNonNull(rootEntry, "rootEntry"); Objects.requireNonNull(rootEntry.getFile(), "rootEntry.getFile()"); this.rootEntry = rootEntry; this.fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.INSTANCE; - switch (IOCase.value(ioCase, IOCase.SYSTEM)) { - case SYSTEM: - this.comparator = NameFileComparator.NAME_SYSTEM_COMPARATOR; - break; - case INSENSITIVE: - this.comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR; - break; - default: - this.comparator = NameFileComparator.NAME_COMPARATOR; - } + this.comparator = Objects.requireNonNull(comparator, "comparator"); + } + + /** + * Constructs an observer for the specified directory, file filter and file comparator. + * + * @param rootEntry the root directory to observe. + * @param fileFilter The file filter or null if none. + * @param ioCase what case sensitivity to use comparing file names, null means system sensitive. + */ + protected FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter, final IOCase ioCase) { + this(rootEntry, fileFilter, toComparator(ioCase)); } /**