org.apache.commons.io.filefilter

## Class NotFileFilter

- java.lang.Object
- - org.apache.commons.io.filefilter.AbstractFileFilter
  - - org.apache.commons.io.filefilter.NotFileFilter

- All Implemented Interfaces:
    FileFilter, FilenameFilter, Serializable, FileVisitor<Path>, PathFilter, PathVisitor, IOFileFilter

      public class NotFileFilter
      extends AbstractFileFilter
      implements Serializable

  This filter produces a logical NOT of the filters specified.
  Since:
    1.0
  See Also:
    `FileFilterUtils.notFileFilter(IOFileFilter)`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface org.apache.commons.io.filefilter.IOFileFilter

      `EMPTY_STRING_ARRAY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NotFileFilter(IOFileFilter filter)` Constructs a new file filter that NOTs the result of another filter.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(File file)` Returns the logical NOT of the underlying filter's return value for the same File.
    `boolean` | `accept(File file, String name)` Returns the logical NOT of the underlying filter's return value for the same arguments.
    `FileVisitResult` | `accept(Path file, BasicFileAttributes attributes)` Returns the logical NOT of the underlying filter's return value for the same File.
    `String` | `toString()` Provide a String representation of this file filter.

    - ### Methods inherited from class org.apache.commons.io.filefilter.AbstractFileFilter

      `handle, postVisitDirectory, preVisitDirectory, visitFile, visitFileFailed`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.io.filefilter.IOFileFilter

      `and, negate, or`

- - ### Constructor Detail

    - #### NotFileFilter

          public NotFileFilter(IOFileFilter filter)

      Constructs a new file filter that NOTs the result of another filter.
      Parameters:
        `filter` - the filter, must not be null
      Throws:
        `IllegalArgumentException` - if the filter is null

  - ### Method Detail

    - #### accept

          public boolean accept(File file)

      Returns the logical NOT of the underlying filter's return value for the same File.
      Specified by:
        `accept` in interface `FileFilter`
      Specified by:
        `accept` in interface `IOFileFilter`
      Overrides:
        `accept` in class `AbstractFileFilter`
      Parameters:
        `file` - the File to check
      Returns:
        true if the filter returns false

    - #### accept

          public boolean accept(File file,
                                String name)

      Returns the logical NOT of the underlying filter's return value for the same arguments.
      Specified by:
        `accept` in interface `FilenameFilter`
      Specified by:
        `accept` in interface `IOFileFilter`
      Overrides:
        `accept` in class `AbstractFileFilter`
      Parameters:
        `file` - the File directory
        `name` - the file name
      Returns:
        true if the filter returns false

    - #### accept

          public FileVisitResult accept(Path file,
                                        BasicFileAttributes attributes)

      Returns the logical NOT of the underlying filter's return value for the same File.
      Specified by:
        `accept` in interface `PathFilter`
      Specified by:
        `accept` in interface `IOFileFilter`
      Parameters:
        `file` - the File to check
        `attributes` - the file's basic attributes (TODO may be null).
      Returns:
        true if the filter returns false
      Since:
        2.9.0

    - #### toString

          public String toString()

      Provide a String representation of this file filter.
      Overrides:
        `toString` in class `AbstractFileFilter`
      Returns:
        a String representation

Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.