Class CompositeFileListFilter<F>
java.lang.Object
org.springframework.integration.file.filters.CompositeFileListFilter<F>
- Type Parameters:
F
- The type that will be filtered.
- All Implemented Interfaces:
Closeable
,AutoCloseable
,DiscardAwareFileListFilter<F>
,FileListFilter<F>
,ResettableFileListFilter<F>
,ReversibleFileListFilter<F>
- Direct Known Subclasses:
ChainFileListFilter
public class CompositeFileListFilter<F>
extends Object
implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, DiscardAwareFileListFilter<F>, Closeable
Simple
FileListFilter
that predicates its matches against all of the
configured FileListFilter
.
Note: when discardCallback
is provided, it is populated to all the
DiscardAwareFileListFilter
delegates. In this case, since this filter
matches the files against all delegates, the discardCallback
may be
called several times for the same file.
- Author:
- Iwein Fuld, Josh Long, Gary Russell, Artem Bilan, Christian Tzolov
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCompositeFileListFilter
(Collection<? extends FileListFilter<F>> fileFilters) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Filter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()
returns true.void
addDiscardCallback
(Consumer<F> discardCallbackToSet) addFilter
(FileListFilter<F> filter) addFilters
(Collection<? extends FileListFilter<F>> filtersToAdd) Add the new filters to this CompositeFileListFilter while maintaining the existing filters.final CompositeFileListFilter<F>
addFilters
(FileListFilter<F>... filters) void
close()
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.boolean
Return true if this filter is being used for recursion.boolean
Remove the specified file from the filter, so it will pass on the next attempt.void
Indicate that not all files previously passed by this filter (inFileListFilter.filterFiles(Object[])
have been processed; the file must be in the list of files; it, and all files after it, will be considered to have not been processed and will be considered next time.boolean
Indicates that this filter supports filtering a single file.
-
Field Details
-
fileFilters
-
-
Constructor Details
-
CompositeFileListFilter
public CompositeFileListFilter() -
CompositeFileListFilter
-
-
Method Details
-
isForRecursion
public boolean isForRecursion()Description copied from interface:FileListFilter
Return true if this filter is being used for recursion.- Specified by:
isForRecursion
in interfaceFileListFilter<F>
- Returns:
- whether or not to filter based on the full path.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
addFilter
-
addFilters
- Parameters:
filters
- one or more new filters to add- Returns:
- this CompositeFileFilter instance with the added filters
- See Also:
-
addFilters
Add the new filters to this CompositeFileListFilter while maintaining the existing filters.- Parameters:
filtersToAdd
- a list of filters to add- Returns:
- this CompositeFileListFilter instance with the added filters
-
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:
-
rollback
Description copied from interface:ReversibleFileListFilter
Indicate that not all files previously passed by this filter (inFileListFilter.filterFiles(Object[])
have been processed; the file must be in the list of files; it, and all files after it, will be considered to have not been processed and will be considered next time.- Specified by:
rollback
in interfaceReversibleFileListFilter<F>
- Parameters:
file
- the file which failed.files
- the list of files that were returned byFileListFilter.filterFiles(Object[])
.
-
remove
Description copied from interface:ResettableFileListFilter
Remove the specified file from the filter, so it will pass on the next attempt.- Specified by:
remove
in interfaceResettableFileListFilter<F>
- Parameters:
f
- the element to remove.- Returns:
- true if the file was removed as a result of this call.
-