Class LastModifiedFileListFilter

java.lang.Object
org.springframework.integration.file.filters.LastModifiedFileListFilter
All Implemented Interfaces:
DiscardAwareFileListFilter<java.io.File>, FileListFilter<java.io.File>

public class LastModifiedFileListFilter
extends java.lang.Object
implements DiscardAwareFileListFilter<java.io.File>
The FileListFilter implementation to filter those files which File.lastModified() is less than the age in comparison with the current time.

The resolution is done in seconds.

When discardCallback is provided, it called for all the rejected files.

Since:
4.2
  • Constructor Summary

    Constructors 
    Constructor Description
    LastModifiedFileListFilter()  
    LastModifiedFileListFilter​(long age)
    Construct a LastModifiedFileListFilter instance with provided age.
  • Method Summary

    Modifier and Type Method Description
    boolean accept​(java.io.File file)
    Filter a single file; only called externally if FileListFilter.supportsSingleFileFiltering() returns true.
    void addDiscardCallback​(java.util.function.Consumer<java.io.File> discardCallbackToSet)  
    java.util.List<java.io.File> filterFiles​(java.io.File[] files)
    Filters out files and returns the files that are left in a list, or an empty list when a null is passed in.
    long getAge()  
    void setAge​(long age)
    Set the age that files have to be before being passed by this filter.
    void setAge​(long age, java.util.concurrent.TimeUnit unit)
    Set the age that files have to be before being passed by this filter.
    void setAge​(java.time.Duration age)
    Set the age that files have to be before being passed by this filter.
    boolean supportsSingleFileFiltering()
    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
  • Constructor Details

  • Method Details

    • setAge

      public void setAge​(long age, java.util.concurrent.TimeUnit unit)
      Set the age that files have to be before being passed by this filter. If File.lastModified() plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.
      Parameters:
      age - the age
      unit - the timeUnit.
    • setAge

      public void setAge​(java.time.Duration age)
      Set the age that files have to be before being passed by this filter. If File.lastModified() plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.
      Parameters:
      age - the age
      Since:
      5.1.3
    • setAge

      public void setAge​(long age)
      Set the age that files have to be before being passed by this filter. If File.lastModified() plus age is greater than the current time, the file is filtered. The resolution is seconds. Defaults to 60 seconds.
      Parameters:
      age - the age
    • getAge

      public long getAge()
    • addDiscardCallback

      public void addDiscardCallback​(@Nullable java.util.function.Consumer<java.io.File> discardCallbackToSet)
      Specified by:
      addDiscardCallback in interface DiscardAwareFileListFilter<java.io.File>
    • filterFiles

      public java.util.List<java.io.File> filterFiles​(java.io.File[] files)
      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 interface FileListFilter<java.io.File>
      Parameters:
      files - The files.
      Returns:
      The filtered files.
    • accept

      public boolean accept​(java.io.File file)
      Description copied from interface: FileListFilter
      Filter a single file; only called externally if FileListFilter.supportsSingleFileFiltering() returns true.
      Specified by:
      accept in interface FileListFilter<java.io.File>
      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: FileListFilter
      Indicates that this filter supports filtering a single file. Filters that return true must override FileListFilter.accept(Object). Default false.
      Specified by:
      supportsSingleFileFiltering in interface FileListFilter<java.io.File>
      Returns:
      true to allow external calls to FileListFilter.accept(Object).
      See Also:
      FileListFilter.accept(Object)