Restrict (Apache Ant API)
Date: 2016-08-23

org.apache.tools.ant.types.resources

## Class Restrict

- java.lang.Object
- - org.apache.tools.ant.ProjectComponent
  - - org.apache.tools.ant.types.DataType
    - - org.apache.tools.ant.types.resources.selectors.ResourceSelectorContainer
      - - org.apache.tools.ant.types.resources.Restrict

- All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<Resource>, ResourceCollection

      public class Restrict
      extends ResourceSelectorContainer
      implements ResourceCollection

  ResourceCollection that allows a number of selectors to be applied to a single ResourceCollection for the purposes of restricting or narrowing results.
  Since:
    Ant 1.7

- - ### Field Summary

    - ### Fields inherited from class org.apache.tools.ant.types.DataType

      `checked, ref`

    - ### Fields inherited from class org.apache.tools.ant.ProjectComponent

      `description, location, project`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Restrict()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(ResourceCollection c)` Add the ResourceCollection.
    `void` | `add(ResourceSelector s)` Add a ResourceSelector.
    `protected void` | `dieOnCircularReference(java.util.Stack<java.lang.Object> stk, Project p)` Overrides the version from DataType to recurse on nested ResourceSelectors.
    `boolean` | `isCache()` Learn whether to cache collections.
    `boolean` | `isFilesystemOnly()` Fulfill the ResourceCollection contract.
    `java.util.Iterator<Resource>` | `iterator()` Fulfill the ResourceCollection contract.
    `void` | `setCache(boolean b)` Set whether to cache collections.
    `int` | `size()` Fulfill the ResourceCollection contract.
    `java.lang.String` | `toString()` Format this Restrict collection as a String.

    - ### Methods inherited from class org.apache.tools.ant.types.resources.selectors.ResourceSelectorContainer

      `getSelectors, hasSelectors, selectorCount`

    - ### Methods inherited from class org.apache.tools.ant.types.DataType

      `checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, setRefid, tooManyAttributes`

    - ### Methods inherited from class org.apache.tools.ant.ProjectComponent

      `getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject`

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### Restrict

          public Restrict()

  - ### Method Detail

    - #### add

          public void add(ResourceCollection c)

      Add the ResourceCollection.
      Parameters:
        `c` - the ResourceCollection to add.

    - #### setCache

          public void setCache(boolean b)

      Set whether to cache collections.
      Parameters:
        `b` - boolean cache flag.

    - #### isCache

          public boolean isCache()

      Learn whether to cache collections. Default is `true`.
      Returns:
        boolean cache flag.

    - #### add

          public void add(ResourceSelector s)

      Add a ResourceSelector.
      Overrides:
        `add` in class `ResourceSelectorContainer`
      Parameters:
        `s` - the ResourceSelector to add.

    - #### iterator

          public final java.util.Iterator<Resource> iterator()

      Fulfill the ResourceCollection contract.
      Specified by:
        `iterator` in interface `java.lang.Iterable<Resource>`
      Specified by:
        `iterator` in interface `ResourceCollection`
      Returns:
        an Iterator of Resources.

    - #### size

          public int size()

      Fulfill the ResourceCollection contract.
      Specified by:
        `size` in interface `ResourceCollection`
      Returns:
        number of elements as int.

    - #### isFilesystemOnly

          public boolean isFilesystemOnly()

      Fulfill the ResourceCollection contract.
      Specified by:
        `isFilesystemOnly` in interface `ResourceCollection`
      Returns:
        whether this is a filesystem-only resource collection.

    - #### toString

          public java.lang.String toString()

      Format this Restrict collection as a String.
      Overrides:
        `toString` in class `DataType`
      Returns:
        the String value of this collection.

    - #### dieOnCircularReference

          protected void dieOnCircularReference(java.util.Stack<java.lang.Object> stk,
                                                Project p)

      Description copied from class: `ResourceSelectorContainer`
      Overrides the version from DataType to recurse on nested ResourceSelectors.
      Overrides:
        `dieOnCircularReference` in class `ResourceSelectorContainer`
      Parameters:
        `stk` - the Stack of references.
        `p` - the Project to resolve against.