public class DeletingVisitor
extends java.nio.file.SimpleFileVisitor<java.nio.file.Path>
Modifier and Type | Field and Description |
---|---|
private java.nio.file.Path |
basePath |
private static Logger |
LOGGER |
private java.util.List<? extends PathCondition> |
pathConditions |
private boolean |
testMode |
Constructor and Description |
---|
DeletingVisitor(java.nio.file.Path basePath,
java.util.List<? extends PathCondition> pathConditions,
boolean testMode)
Constructs a new DeletingVisitor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
delete(java.nio.file.Path file)
Deletes the specified file.
|
boolean |
isTestMode()
Returns
true if files are not deleted even when all conditions accept a path, false otherwise. |
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attrs) |
private static final Logger LOGGER
private final java.nio.file.Path basePath
private final boolean testMode
private final java.util.List<? extends PathCondition> pathConditions
public DeletingVisitor(java.nio.file.Path basePath, java.util.List<? extends PathCondition> pathConditions, boolean testMode)
basePath
- used to relativize pathspathConditions
- objects that need to confirm whether a file can be deletedtestMode
- if true, files are not deleted but instead a message is printed to the status logger
at INFO level. Users can use this to do a dry run to test if their configuration works as expected.public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
visitFile
in interface java.nio.file.FileVisitor<java.nio.file.Path>
visitFile
in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>
java.io.IOException
protected void delete(java.nio.file.Path file) throws java.io.IOException
file
- the file to deletejava.io.IOException
- if a problem occurred deleting the filepublic boolean isTestMode()
true
if files are not deleted even when all conditions accept a path, false
otherwise.true
if files are not deleted even when all conditions accept a path, false
otherwise