Skip to content

Commit f6655cf

Browse files
author
Gary Gregory
committed
Refactor common code into a private method.
1 parent b60ce43 commit f6655cf

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,7 @@ public PrefixFileFilter(final String[] prefixes, final IOCase caseSensitivity) {
146146
*/
147147
@Override
148148
public boolean accept(final File file) {
149-
final String name = file.getName();
150-
for (final String prefix : this.prefixes) {
151-
if (caseSensitivity.checkStartsWith(name, prefix)) {
152-
return true;
153-
}
154-
}
155-
return false;
149+
return accept(file.getName());
156150
}
157151

158152
/**
@@ -164,6 +158,10 @@ public boolean accept(final File file) {
164158
*/
165159
@Override
166160
public boolean accept(final File file, final String name) {
161+
return accept(name);
162+
}
163+
164+
private boolean accept(final String name) {
167165
for (final String prefix : prefixes) {
168166
if (caseSensitivity.checkStartsWith(name, prefix)) {
169167
return true;

0 commit comments

Comments
 (0)