public class LastModifiedFileListFilter extends Object implements DiscardAwareFileListFilter<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 |
|---|---|
boolean |
accept(File file)
Filter a single file; only called externally if
FileListFilter.supportsSingleFileFiltering()
returns true. |
void |
addDiscardCallback(java.util.function.Consumer<File> discardCallbackToSet) |
List<File> |
filterFiles(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(java.time.Duration age)
Set the age that files have to be before being passed by this filter.
|
void |
setAge(long age)
Set the age that files have to be before being passed by this filter.
|
void |
setAge(long age,
TimeUnit unit)
Set the age that files have to be before being passed by this filter.
|
boolean |
supportsSingleFileFiltering()
Indicates that this filter supports filtering a single file.
|
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,
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 setAge(java.time.Duration 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 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 addDiscardCallback(@Nullable java.util.function.Consumer<File> discardCallbackToSet)
addDiscardCallback in interface DiscardAwareFileListFilter<File>public List<File> filterFiles(File[] files)
FileListFilterfilterFiles in interface FileListFilter<File>files - The files.public boolean accept(File file)
FileListFilterFileListFilter.supportsSingleFileFiltering()
returns true.accept in interface FileListFilter<File>file - the file.FileListFilter.supportsSingleFileFiltering()public boolean supportsSingleFileFiltering()
FileListFilterFileListFilter.accept(Object).
Default false.supportsSingleFileFiltering in interface FileListFilter<File>FileListFilter.accept(Object).FileListFilter.accept(Object)