Class AbstractLastModifiedFileListFilter<F>
java.lang.Object
org.springframework.integration.file.filters.AbstractLastModifiedFileListFilter<F>
- Type Parameters:
F
- the file
- All Implemented Interfaces:
DiscardAwareFileListFilter<F>
,FileListFilter<F>
- Direct Known Subclasses:
FtpLastModifiedFileListFilter
,LastModifiedFileListFilter
,SftpLastModifiedFileListFilter
,SmbLastModifiedFileListFilter
public abstract class AbstractLastModifiedFileListFilter<F>
extends Object
implements DiscardAwareFileListFilter<F>
The
FileListFilter
implementation to filter those files which
lastModified is less than the age
in comparison
with the Instant.now()
.
When discardCallback
is provided, it called for all the rejected files.- Since:
- 6.2
- Author:
- Adama Sorho, Artem Bilan
-
Field Summary
-
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionboolean
Filter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()
returns true.void
addDiscardCallback
(Consumer<F> discardCallback) filterFiles
(F[] files) Filters out files and returns the files that are left in a list, or an empty list when a null is passed in.protected Duration
protected abstract Instant
getLastModified
(F remoteFile) void
setAge
(long age) Set the age that files have to be before being passed by this filter.void
Set the age that files have to be before being passed by this filter.boolean
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
-
Field Details
-
ONE_SECOND
protected static final long ONE_SECOND- See Also:
-
-
Constructor Details
-
AbstractLastModifiedFileListFilter
public AbstractLastModifiedFileListFilter() -
AbstractLastModifiedFileListFilter
-
-
Method Details
-
setAge
Set the age that files have to be before being passed by this filter. If lastModified plusage
is before theInstant.now()
, the file is filtered. Defaults to 60 seconds.- Parameters:
age
- the Duration.
-
setAge
public void setAge(long age) Set the age that files have to be before being passed by this filter. If lastModified plusage
is before theInstant.now()
, the file is filtered. Defaults to 60 seconds.- Parameters:
age
- the age in seconds.
-
addDiscardCallback
- Specified by:
addDiscardCallback
in interfaceDiscardAwareFileListFilter<F>
-
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<F>
- 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<F>
- Parameters:
file
- the file.- Returns:
- true if the file passes the filter, false to filter.
- See Also:
-
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<F>
- Returns:
- true to allow external calls to
FileListFilter.accept(Object)
. - See Also:
-
getAgeDuration
-
getLastModified
-