Fix file filter and reduce it down to 1 line.

This commit is contained in:
Keir 2015-12-24 21:25:55 +00:00
parent cc421c1435
commit 2252a5397d
2 changed files with 1 additions and 35 deletions

View File

@ -1,34 +0,0 @@
package mineplex.chatsnap;
import java.io.File;
import java.io.FileFilter;
import java.util.UUID;
/**
* @author iKeirNez
*/
public class ChatSnapFileFilter implements FileFilter
{
private static final String FILE_EXTENSION = ".json";
@Override
public boolean accept(File file)
{
String fileName = file.getName();
if (file.isFile() && fileName.endsWith(FILE_EXTENSION))
{
String uuid = fileName.substring(0, fileName.length() - FILE_EXTENSION.length());
try
{
// this will trigger the catch block if invalid
UUID.fromString(uuid);
return true;
}
catch (IllegalArgumentException e) {}
}
return false;
}
}

View File

@ -10,7 +10,7 @@ import java.util.logging.Logger;
*/
public class PurgeTask implements Runnable
{
private static final FileFilter FILE_FILTER = new ChatSnapFileFilter();
private static final FileFilter FILE_FILTER = file -> file.isFile() && file.getName().endsWith(".json");
private final File _dataDir;
private final Logger _logger;