F - The type that will be filtered.public class CompositeFileListFilter<F> extends Object implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, DiscardAwareFileListFilter<F>, Closeable
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.
| Modifier and Type | Field and Description |
|---|---|
protected Set<FileListFilter<F>> |
fileFilters |
| Constructor and Description |
|---|
CompositeFileListFilter() |
CompositeFileListFilter(Collection<? extends FileListFilter<F>> fileFilters) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(F file)
Filter a single file; only called externally if
FileListFilter.supportsSingleFileFiltering()
returns true. |
void |
addDiscardCallback(java.util.function.Consumer<F> discardCallbackToSet) |
CompositeFileListFilter<F> |
addFilter(FileListFilter<F> filter) |
CompositeFileListFilter<F> |
addFilters(Collection<? extends FileListFilter<F>> filtersToAdd)
Not thread safe.
|
CompositeFileListFilter<F> |
addFilters(FileListFilter<F>... filters) |
void |
close() |
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.
|
boolean |
remove(F f)
Remove the specified file from the filter so it will pass on the next attempt.
|
void |
rollback(F file,
List<F> files)
Indicate that not all files previously passed by this filter (in
FileListFilter.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 |
supportsSingleFileFiltering()
Indicates that this filter supports filtering a single file.
|
protected final Set<FileListFilter<F>> fileFilters
public CompositeFileListFilter()
public CompositeFileListFilter(Collection<? extends FileListFilter<F>> fileFilters)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic CompositeFileListFilter<F> addFilter(FileListFilter<F> filter)
@SafeVarargs public final CompositeFileListFilter<F> addFilters(FileListFilter<F>... filters)
filters - one or more new filters to addaddFilters(Collection)public CompositeFileListFilter<F> addFilters(Collection<? extends FileListFilter<F>> filtersToAdd)
Add the new filters to this CompositeFileListFilter while maintaining the existing filters.
filtersToAdd - a list of filters to addpublic void addDiscardCallback(java.util.function.Consumer<F> discardCallbackToSet)
addDiscardCallback in interface DiscardAwareFileListFilter<F>public List<F> filterFiles(F[] files)
FileListFilterfilterFiles in interface FileListFilter<F>files - The files.public boolean accept(F file)
FileListFilterFileListFilter.supportsSingleFileFiltering()
returns true.accept in interface FileListFilter<F>file - the file.FileListFilter.supportsSingleFileFiltering()public boolean supportsSingleFileFiltering()
FileListFilterFileListFilter.accept(Object).
Default false.supportsSingleFileFiltering in interface FileListFilter<F>FileListFilter.accept(Object).FileListFilter.accept(Object)public void rollback(F file, List<F> files)
ReversibleFileListFilterFileListFilter.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.rollback in interface ReversibleFileListFilter<F>file - the file which failed.files - the list of files that were returned by FileListFilter.filterFiles(Object[]).public boolean remove(F f)
ResettableFileListFilterremove in interface ResettableFileListFilter<F>f - the element to remove.