public class LastModifiedFileListFilter extends java.lang.Object implements DiscardAwareFileListFilter<java.io.File>
FileListFilter
implementation to filter those files which
File.lastModified()
is less than the age
in comparison
with the current time.
The resolution is done in seconds.
When discardCallback
is provided, it called for all the
rejected files.
Constructor and Description |
---|
LastModifiedFileListFilter() |
LastModifiedFileListFilter(long age)
Construct a
LastModifiedFileListFilter instance with provided age . |
Modifier and Type | Method and Description |
---|---|
void |
addDiscardCallback(java.util.function.Consumer<java.io.File> discardCallback) |
java.util.List<java.io.File> |
filterFiles(java.io.File[] files)
Filters out files and returns the files that are left in a list, or an
empty list when a null is passed in.
|
long |
getAge() |
void |
setAge(long age)
Set the age that files have to be before being passed by this filter.
|
void |
setAge(long age,
java.util.concurrent.TimeUnit unit)
Set the age that files have to be before being passed by this filter.
|
public LastModifiedFileListFilter()
public LastModifiedFileListFilter(long age)
LastModifiedFileListFilter
instance with provided age
.
Defaults to 60 seconds.age
- the age in seconds.public void setAge(long age)
File.lastModified()
plus age is greater than the current time, the file
is filtered. The resolution is seconds.
Defaults to 60 seconds.age
- the agepublic long getAge()
public void setAge(long age, java.util.concurrent.TimeUnit unit)
File.lastModified()
plus age is greater than the current time, the file
is filtered. The resolution is seconds.
Defaults to 60 seconds.age
- the ageunit
- the timeUnit.public void addDiscardCallback(java.util.function.Consumer<java.io.File> discardCallback)
addDiscardCallback
in interface DiscardAwareFileListFilter<java.io.File>
public java.util.List<java.io.File> filterFiles(java.io.File[] files)
FileListFilter
filterFiles
in interface FileListFilter<java.io.File>
files
- The files.