F
- The type that will be filtered.public class CompositeFileListFilter<F> extends java.lang.Object implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, DiscardAwareFileListFilter<F>, java.io.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 java.util.Set<FileListFilter<F>> |
fileFilters |
Constructor and Description |
---|
CompositeFileListFilter() |
CompositeFileListFilter(java.util.Collection<? extends FileListFilter<F>> fileFilters) |
Modifier and Type | Method and Description |
---|---|
void |
addDiscardCallback(java.util.function.Consumer<F> discardCallback) |
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) |
void |
close() |
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.
|
boolean |
remove(F f)
Remove the specified file from the filter so it will pass on the next attempt.
|
void |
rollback(F file,
java.util.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. |
protected final java.util.Set<FileListFilter<F>> fileFilters
public CompositeFileListFilter()
public CompositeFileListFilter(java.util.Collection<? extends FileListFilter<F>> fileFilters)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public CompositeFileListFilter<F> addFilter(FileListFilter<F> filter)
public CompositeFileListFilter<F> addFilters(FileListFilter<F>... filters)
filters
- one or more new filters to addaddFilters(Collection)
public CompositeFileListFilter<F> addFilters(java.util.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> discardCallback)
addDiscardCallback
in interface DiscardAwareFileListFilter<F>
public java.util.List<F> filterFiles(F[] files)
FileListFilter
filterFiles
in interface FileListFilter<F>
files
- The files.public void rollback(F file, java.util.List<F> files)
ReversibleFileListFilter
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.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)
ResettableFileListFilter
remove
in interface ResettableFileListFilter<F>
f
- the element to remove.