Class LastModifiedFileListFilter
java.lang.Object
org.springframework.integration.file.filters.LastModifiedFileListFilter
- All Implemented Interfaces:
DiscardAwareFileListFilter<File>
,FileListFilter<File>
public class LastModifiedFileListFilter extends Object implements DiscardAwareFileListFilter<File>
The
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.
- Since:
- 4.2
- Author:
- Gary Russell, Artem Bilan
-
Constructor Summary
Constructors Constructor Description LastModifiedFileListFilter()
LastModifiedFileListFilter(long age)
Construct aLastModifiedFileListFilter
instance with providedage
. -
Method Summary
Modifier and Type Method Description boolean
accept(File file)
Filter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()
returns true.void
addDiscardCallback(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(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.void
setAge(Duration age)
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.file.filters.FileListFilter
isForRecursion
-
Constructor Details
-
LastModifiedFileListFilter
public LastModifiedFileListFilter() -
LastModifiedFileListFilter
public LastModifiedFileListFilter(long age)Construct aLastModifiedFileListFilter
instance with providedage
. Defaults to 60 seconds.- Parameters:
age
- the age in seconds.- Since:
- 5.0
-
-
Method Details
-
setAge
Set the age that files have to be before being passed by this filter. IfFile.lastModified()
plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.- Parameters:
age
- the ageunit
- the timeUnit.
-
setAge
Set the age that files have to be before being passed by this filter. IfFile.lastModified()
plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.- Parameters:
age
- the age- Since:
- 5.1.3
-
setAge
public void setAge(long age)Set the age that files have to be before being passed by this filter. IfFile.lastModified()
plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.- Parameters:
age
- the age
-
getAge
public long getAge() -
addDiscardCallback
- Specified by:
addDiscardCallback
in interfaceDiscardAwareFileListFilter<File>
-
filterFiles
Description copied from interface:FileListFilter
Filters out files and returns the files that are left in a list, or an empty list when a null is passed in.- Specified by:
filterFiles
in interfaceFileListFilter<File>
- Parameters:
files
- The files.- Returns:
- The filtered files.
-
accept
Description copied from interface:FileListFilter
Filter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()
returns true.- Specified by:
accept
in interfaceFileListFilter<File>
- Parameters:
file
- the file.- Returns:
- true if the file passes the filter, false to filter.
- See Also:
FileListFilter.supportsSingleFileFiltering()
-
supportsSingleFileFiltering
public boolean supportsSingleFileFiltering()Description copied from interface:FileListFilter
Indicates that this filter supports filtering a single file. Filters that return true must overrideFileListFilter.accept(Object)
. Default false.- Specified by:
supportsSingleFileFiltering
in interfaceFileListFilter<File>
- Returns:
- true to allow external calls to
FileListFilter.accept(Object)
. - See Also:
FileListFilter.accept(Object)
-