Skip to content

Commit

Permalink
Refactored filename filter into static class
Browse files Browse the repository at this point in the history
  • Loading branch information
hammerhead committed Dec 4, 2011
1 parent 65b5b2b commit e202725
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/main/java/de/kabambo/maven/optipng/OptimizePngMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public OptimizePngMojo() {
pool = Executors.newCachedThreadPool();
}

/**
* A filename filter for PNG files.
*/
private static class PngFilenameFilter implements FilenameFilter {
@Override
public boolean accept(final File dir, final String name) {
return name.endsWith(PNG_SUFFIX);
}
}

/**
* Executes the mojo.
*
Expand Down Expand Up @@ -123,12 +133,7 @@ public void execute() throws MojoExecutionException {
"The path %s is not a directory.", directory));
}

File[] containedImages = d.listFiles(new FilenameFilter() {
@Override
public boolean accept(final File dir, final String name) {
return name.endsWith(PNG_SUFFIX);
}
});
File[] containedImages = d.listFiles(new PngFilenameFilter());

numberImages += containedImages.length;
for (File image : containedImages) {
Expand Down

0 comments on commit e202725

Please sign in to comment.