# Class PatternSet

java.lang.Object
org.gradle.api.tasks.util.PatternSet

All Implemented Interfaces:
  `AntBuilderAware, PatternFilterable`

public class PatternSet extends Object implements AntBuilderAware, PatternFilterable
Standalone implementation of `PatternFilterable`.

Since:
  0.7

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `PatternSet()`
  Creates a new `PatternSet`.
  `protected`
  `PatternSet(org.gradle.api.tasks.util.internal.PatternSpecFactory patternSpecFactory)`
  Creates a new `PatternSet`.
  `protected`
  `PatternSet(PatternSet patternSet)`
  Creates a new `PatternSet`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `addToAntBuilder(Object node, String childNodeName)`
  Add to ant builder.
  `PatternSet`
  `copyFrom(PatternFilterable sourcePattern)`
  Copy.
  `protected PatternSet`
  `doCopyFrom(PatternSet from)`
  Do copy.
  `boolean`
  `equals(@Nullable Object o)`
  `PatternSet`
  `exclude(Closure closure)`
  Adds an exclude spec.
  `PatternSet`
  `exclude(Iterable excludes)`
  Adds an Ant style exclude pattern.
  `PatternSet`
  `exclude(String... excludes)`
  Adds an Ant style exclude pattern.
  `PatternSet`
  `exclude(Spec<FileTreeElement> spec)`
  Adds an exclude spec.
  `PatternSet`
  `excludeSpecs(Iterable<Spec<FileTreeElement>> excludes)`
  Exclude specs.
  `Spec<FileTreeElement>`
  `getAsExcludeSpec()`
  Returns the as exclude spec.
  `Spec<FileTreeElement>`
  `getAsIncludeSpec()`
  Returns the as include spec.
  `Spec<FileTreeElement>`
  `getAsSpec()`
  Returns the as spec.
  `Set<String>`
  `getExcludes()`
  Returns the set of exclude patterns.
  `Set<Spec<FileTreeElement>>`
  `getExcludeSpecs()`
  Returns the exclude specs.
  `Set<Spec<FileTreeElement>>`
  `getExcludeSpecsView()`
  Like `getExcludeSpecs()`, but returns a unmodifiable view or empty set.
  `Set<String>`
  `getExcludesView()`
  Like `getExcludes()`, but returns a unmodifiable view or empty set.
  `Set<String>`
  `getIncludes()`
  Returns the set of include patterns.
  `Set<Spec<FileTreeElement>>`
  `getIncludeSpecs()`
  Returns the include specs.
  `Set<Spec<FileTreeElement>>`
  `getIncludeSpecsView()`
  Like `getIncludeSpecs()`, but returns a unmodifiable view or empty set.
  `Set<String>`
  `getIncludesView()`
  Like `getIncludes()`, but returns a unmodifiable view or empty set.
  `int`
  `hashCode()`
  `PatternSet`
  `include(Closure closure)`
  Adds an include spec.
  `PatternSet`
  `include(Iterable includes)`
  Adds an Ant style include pattern.
  `PatternSet`
  `include(String... includes)`
  Adds an Ant style include pattern.
  `PatternSet`
  `include(Spec<FileTreeElement> spec)`
  Adds an include spec.
  `PatternSet`
  `includeSpecs(Iterable<Spec<FileTreeElement>> includeSpecs)`
  Include specs.
  `PatternSet`
  `intersect()`
  Intersect.
  `boolean`
  `isCaseSensitive()`
  Returns whether case sensitive is set.
  `boolean`
  `isEmpty()`
  The PatternSet is considered empty when no includes or excludes have been added.
  `void`
  `setCaseSensitive(boolean caseSensitive)`
  Sets the case sensitive.
  `PatternSet`
  `setExcludes(Iterable<String> excludes)`
  Set the allowable exclude patterns.
  `PatternSet`
  `setIncludes(Iterable<String> includes)`
  Set the allowable include patterns.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PatternSet

    public PatternSet()
    Creates a new `PatternSet`.
    Since:
      0.7

  - ### PatternSet

    protected PatternSet(PatternSet patternSet)
    Creates a new `PatternSet`.
    Since:
      2.11

  - ### PatternSet

    protected PatternSet(org.gradle.api.tasks.util.internal.PatternSpecFactory patternSpecFactory)
    Creates a new `PatternSet`.
    Since:
      2.11

- ## Method Details

  - ### equals

    public boolean equals(@Nullable Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### copyFrom

    public PatternSet copyFrom(PatternFilterable sourcePattern)
    Copy.
    Since:
      0.8

  - ### doCopyFrom

    protected PatternSet doCopyFrom(PatternSet from)
    Do copy.
    Since:
      2.5

  - ### intersect

    public PatternSet intersect()
    Intersect.
    Since:
      0.8

  - ### isEmpty

    public boolean isEmpty()
    The PatternSet is considered empty when no includes or excludes have been added. The Spec returned by getAsSpec method only contains the default excludes patterns in this case.
    Returns:
      true when no includes or excludes have been added to this instance
    Since:
      2.13

  - ### getAsSpec

    public Spec<FileTreeElement> getAsSpec()
    Returns the as spec.
    Since:
      0.8

  - ### getAsIncludeSpec

    public Spec<FileTreeElement> getAsIncludeSpec()
    Returns the as include spec.
    Since:
      1.4

  - ### getAsExcludeSpec

    public Spec<FileTreeElement> getAsExcludeSpec()
    Returns the as exclude spec.
    Since:
      1.4

  - ### getIncludesView

    @Incubating public Set<String> getIncludesView()
    Like `getIncludes()`, but returns a unmodifiable view or empty set.

    Use this if you are only reading from the set, as it avoids allocating a set if not needed.

    Returns:
      the include patterns, or an empty set if none
    Since:
      8.8

  - ### getIncludes

    public Set<String> getIncludes()
    Description copied from interface: `PatternFilterable`
    Returns the set of include patterns.
    Specified by:
      `getIncludes` in interface `PatternFilterable`
    Returns:
      The include patterns. Returns an empty set when there are no include patterns.

  - ### getIncludeSpecsView

    @Incubating public Set<Spec<FileTreeElement>> getIncludeSpecsView()
    Like `getIncludeSpecs()`, but returns a unmodifiable view or empty set.

    Use this if you are only reading from the set, as it avoids allocating a set if not needed.

    Returns:
      the include specs, or an empty set if none
    Since:
      8.8

  - ### getIncludeSpecs

    public Set<Spec<FileTreeElement>> getIncludeSpecs()
    Returns the include specs.
    Since:
      0.9

  - ### setIncludes

    public PatternSet setIncludes(Iterable<String> includes)
    Description copied from interface: `PatternFilterable`
    Set the allowable include patterns. Note that unlike `PatternFilterable.include(Iterable)` this replaces any previously defined includes.
    Specified by:
      `setIncludes` in interface `PatternFilterable`
    Parameters:
      `includes` - an Iterable providing new include patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### include

    public PatternSet include(String... includes)
    Description copied from interface: `PatternFilterable`
    Adds an Ant style include pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns to be processed.
    Specified by:
      `include` in interface `PatternFilterable`
    Parameters:
      `includes` - a vararg list of include patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### include

    public PatternSet include(Iterable includes)
    Description copied from interface: `PatternFilterable`
    Adds an Ant style include pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns to be processed.
    Specified by:
      `include` in interface `PatternFilterable`
    Parameters:
      `includes` - a Iterable providing more include patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### include

    public PatternSet include(Spec<FileTreeElement> spec)
    Description copied from interface: `PatternFilterable`
    Adds an include spec. This method may be called multiple times to append new specs. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.
    Specified by:
      `include` in interface `PatternFilterable`
    Parameters:
      `spec` - the spec to add
    Returns:
      this
    See Also:
      - Pattern Format

  - ### getExcludesView

    @Incubating public Set<String> getExcludesView()
    Like `getExcludes()`, but returns a unmodifiable view or empty set.

    Use this if you are only reading from the set, as it avoids allocating a set if not needed.

    Returns:
      the exclude patterns, or an empty set if none
    Since:
      8.8

  - ### getExcludes

    public Set<String> getExcludes()
    Description copied from interface: `PatternFilterable`
    Returns the set of exclude patterns.
    Specified by:
      `getExcludes` in interface `PatternFilterable`
    Returns:
      The exclude patterns. Returns an empty set when there are no exclude patterns.

  - ### getExcludeSpecsView

    @Incubating public Set<Spec<FileTreeElement>> getExcludeSpecsView()
    Like `getExcludeSpecs()`, but returns a unmodifiable view or empty set.

    Use this if you are only reading from the set, as it avoids allocating a set if not needed.

    Returns:
      the exclude specs, or an empty set if none
    Since:
      8.8

  - ### getExcludeSpecs

    public Set<Spec<FileTreeElement>> getExcludeSpecs()
    Returns the exclude specs.
    Since:
      0.9

  - ### setExcludes

    public PatternSet setExcludes(Iterable<String> excludes)
    Description copied from interface: `PatternFilterable`
    Set the allowable exclude patterns. Note that unlike `PatternFilterable.exclude(Iterable)` this replaces any previously defined excludes.
    Specified by:
      `setExcludes` in interface `PatternFilterable`
    Parameters:
      `excludes` - an Iterable providing new exclude patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### isCaseSensitive

    public boolean isCaseSensitive()
    Returns whether case sensitive is set.
    Since:
      0.8

  - ### setCaseSensitive

    public void setCaseSensitive(boolean caseSensitive)
    Sets the case sensitive.
    Since:
      0.8

  - ### includeSpecs

    public PatternSet includeSpecs(Iterable<Spec<FileTreeElement>> includeSpecs)
    Include specs.
    Since:
      0.9

  - ### include

    public PatternSet include(Closure closure)
    Description copied from interface: `PatternFilterable`
    Adds an include spec. This method may be called multiple times to append new specs. The given closure is passed a `FileTreeElement` as its parameter. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.
    Specified by:
      `include` in interface `PatternFilterable`
    Parameters:
      `closure` - the spec to add
    Returns:
      this
    See Also:
      - Pattern Format

  - ### exclude

    public PatternSet exclude(String... excludes)
    Description copied from interface: `PatternFilterable`
    Adds an Ant style exclude pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.
    Specified by:
      `exclude` in interface `PatternFilterable`
    Parameters:
      `excludes` - a vararg list of exclude patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### exclude

    public PatternSet exclude(Iterable excludes)
    Description copied from interface: `PatternFilterable`
    Adds an Ant style exclude pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.
    Specified by:
      `exclude` in interface `PatternFilterable`
    Parameters:
      `excludes` - a Iterable providing new exclude patterns
    Returns:
      this
    See Also:
      - Pattern Format

  - ### exclude

    public PatternSet exclude(Spec<FileTreeElement> spec)
    Description copied from interface: `PatternFilterable`
    Adds an exclude spec. This method may be called multiple times to append new specs. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.
    Specified by:
      `exclude` in interface `PatternFilterable`
    Parameters:
      `spec` - the spec to add
    Returns:
      this
    See Also:
      - Pattern Format

  - ### excludeSpecs

    public PatternSet excludeSpecs(Iterable<Spec<FileTreeElement>> excludes)
    Exclude specs.
    Since:
      0.9

  - ### exclude

    public PatternSet exclude(Closure closure)
    Description copied from interface: `PatternFilterable`
    Adds an exclude spec. This method may be called multiple times to append new specs.The given closure is passed a `FileTreeElement` as its parameter. The closure should return true or false. Example:

        copySpec {
          from 'source'
          into 'destination'
          //an example of excluding files from certain configuration:
          exclude { it.file in configurations.someConf.files }
        }

    If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.
    Specified by:
      `exclude` in interface `PatternFilterable`
    Parameters:
      `closure` - the spec to add
    Returns:
      this
    See Also:
      - `FileTreeElement`

  - ### addToAntBuilder

    public Object addToAntBuilder(Object node, String childNodeName)
    Description copied from interface: `AntBuilderAware`
    Add to ant builder.
    Specified by:
      `addToAntBuilder` in interface `AntBuilderAware`