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:
java.io.Closeable,java.lang.AutoCloseable,DiscardAwareFileListFilter<F>,FileListFilter<F>,ResettableFileListFilter<F>,ReversibleFileListFilter<F>
- Direct Known Subclasses:
ChainFileListFilter
public class CompositeFileListFilter<F> extends java.lang.Object implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, DiscardAwareFileListFilter<F>, java.io.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.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<FileListFilter<F>>fileFilters -
Constructor Summary
Constructors Constructor Description CompositeFileListFilter()CompositeFileListFilter(java.util.Collection<? extends FileListFilter<F>> fileFilters) -
Method Summary
Modifier and Type Method Description booleanaccept(F file)Filter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()returns true.voidaddDiscardCallback(java.util.function.Consumer<F> discardCallbackToSet)CompositeFileListFilter<F>addFilter(FileListFilter<F> filter)CompositeFileListFilter<F>addFilters(java.util.Collection<? extends FileListFilter<F>> filtersToAdd)Not thread safe.CompositeFileListFilter<F>addFilters(FileListFilter<F>... filters)voidclose()java.util.List<F>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.booleanremove(F f)Remove the specified file from the filter so it will pass on the next attempt.voidrollback(F file, java.util.List<F> files)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.booleansupportsSingleFileFiltering()Indicates that this filter supports filtering a single file.
-
Field Details
-
Constructor Details
-
CompositeFileListFilter
public CompositeFileListFilter() -
CompositeFileListFilter
-
-
Method Details
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
addFilter
-
addFilters
- Parameters:
filters- one or more new filters to add- Returns:
- this CompositeFileFilter instance with the added filters
- See Also:
addFilters(Collection)
-
addFilters
public CompositeFileListFilter<F> addFilters(java.util.Collection<? extends FileListFilter<F>> filtersToAdd)Not thread safe. Only a single thread may add filters at a time.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:
addDiscardCallbackin interfaceDiscardAwareFileListFilter<F>
-
filterFiles
Description copied from interface:FileListFilterFilters out files and returns the files that are left in a list, or an empty list when a null is passed in.- Specified by:
filterFilesin interfaceFileListFilter<F>- Parameters:
files- The files.- Returns:
- The filtered files.
-
accept
Description copied from interface:FileListFilterFilter a single file; only called externally ifFileListFilter.supportsSingleFileFiltering()returns true.- Specified by:
acceptin interfaceFileListFilter<F>- 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:FileListFilterIndicates that this filter supports filtering a single file. Filters that return true must overrideFileListFilter.accept(Object). Default false.- Specified by:
supportsSingleFileFilteringin interfaceFileListFilter<F>- Returns:
- true to allow external calls to
FileListFilter.accept(Object). - See Also:
FileListFilter.accept(Object)
-
rollback
Description copied from interface:ReversibleFileListFilterIndicate 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:
rollbackin interfaceReversibleFileListFilter<F>- Parameters:
file- the file which failed.files- the list of files that were returned byFileListFilter.filterFiles(Object[]).
-
remove
Description copied from interface:ResettableFileListFilterRemove the specified file from the filter so it will pass on the next attempt.- Specified by:
removein interfaceResettableFileListFilter<F>- Parameters:
f- the element to remove.- Returns:
- true if the file was removed as a result of this call.
-