com.sun.mirror.util

## Class DeclarationFilter

- java.lang.Object
- - com.sun.mirror.util.DeclarationFilter

- Deprecated.
  All components of this API have been superseded by the standardized annotation processing API. The replacement for the functionality of this class is `ElementFilter`.

      @Deprecated
      public class DeclarationFilter
      extends Object

  A filter for selecting just the items of interest from a collection of declarations. The filter is said to select or to match those declarations. Filters can be created in several ways: by the static methods described below, by negating or composing existing filters, or by subclasses that implement arbitrary matching rules.

  A subclass can create an arbitrary filter simply by implementing the `matches(Declaration)` method.

  Examples.

  Selecting the `public` declarations from a collection:

  >          result = FILTER_PUBLIC.filter(decls);

  Selecting class declarations (including enums):

  >          classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
  >          result = classFilter.filter(decls);

  Selecting class declarations but excluding enums:

  >          enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
  >          compoundFilter = classFilter.and(enumFilter.not());
  >          result = compoundFilter.filter(decls);

  Selecting declarations named "Bob":

  >          nameFilter = new DeclarationFilter() {
  >                           public boolean matches(Declaration d) {
  >                               return d.getSimpleName().equals("Bob");
  >                           }
  >                       };
  >          result = nameFilter.filter(decls);

  Since:
    1.5

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DeclarationFilter` | `FILTER_PACKAGE` Deprecated. A filter that selects only package-private (default) declarations.
    `static DeclarationFilter` | `FILTER_PRIVATE` Deprecated. A filter that selects only `private` declarations.
    `static DeclarationFilter` | `FILTER_PROTECTED` Deprecated. A filter that selects only `protected` declarations.
    `static DeclarationFilter` | `FILTER_PUBLIC` Deprecated. A filter that selects only `public` declarations.
    `static DeclarationFilter` | `FILTER_PUBLIC_OR_PROTECTED` Deprecated. A filter that selects only `public` or `protected` declarations.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeclarationFilter()` Deprecated. Constructs an identity filter: one that selects all declarations.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DeclarationFilter` | `and(DeclarationFilter f)` Deprecated. Returns a filter that selects those declarations selected by both this filter and another.
    `<D extends Declaration> Collection<D>` | `filter(Collection<? extends Declaration> decls, Class<D> resType)` Deprecated. Returns the declarations matched by this filter, with the result being restricted to declarations of a given kind.
    `<D extends Declaration> Collection<D>` | `filter(Collection<D> decls)` Deprecated. Returns the declarations matched by this filter.
    `static DeclarationFilter` | `getFilter(Class<? extends Declaration> kind)` Deprecated. Returns a filter that selects declarations of a particular kind.
    `static DeclarationFilter` | `getFilter(Collection<Modifier> mods)` Deprecated. Returns a filter that selects declarations containing all of a collection of modifiers.
    `boolean` | `matches(Declaration decl)` Deprecated. Tests whether this filter matches a given declaration.
    `DeclarationFilter` | `not()` Deprecated. Returns a filter that selects those declarations not selected by this filter.
    `DeclarationFilter` | `or(DeclarationFilter f)` Deprecated. Returns a filter that selects those declarations selected by either this filter or another.

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

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

- - ### Field Detail

    - #### FILTER_PUBLIC

          public static final DeclarationFilter FILTER_PUBLIC

      Deprecated.
      A filter that selects only `public` declarations.

    - #### FILTER_PROTECTED

          public static final DeclarationFilter FILTER_PROTECTED

      Deprecated.
      A filter that selects only `protected` declarations.

    - #### FILTER_PUBLIC_OR_PROTECTED

          public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED

      Deprecated.
      A filter that selects only `public` or `protected` declarations.

    - #### FILTER_PACKAGE

          public static final DeclarationFilter FILTER_PACKAGE

      Deprecated.
      A filter that selects only package-private (default) declarations.

    - #### FILTER_PRIVATE

          public static final DeclarationFilter FILTER_PRIVATE

      Deprecated.
      A filter that selects only `private` declarations.

  - ### Constructor Detail

    - #### DeclarationFilter

          public DeclarationFilter()

      Deprecated.
      Constructs an identity filter: one that selects all declarations.

  - ### Method Detail

    - #### getFilter

          public static DeclarationFilter getFilter(Collection<Modifier> mods)

      Deprecated.
      Returns a filter that selects declarations containing all of a collection of modifiers.
      Parameters:
        `mods` - the modifiers to match (non-null)
      Returns:
        a filter that matches declarations containing `mods`

    - #### getFilter

          public static DeclarationFilter getFilter(Class<? extends Declaration> kind)

      Deprecated.
      Returns a filter that selects declarations of a particular kind. For example, there may be a filter that selects only class declarations, or only fields. The filter will select declarations of the specified kind, and also any subtypes of that kind; for example, a field filter will also select enum constants.
      Parameters:
        `kind` - the kind of declarations to select
      Returns:
        a filter that selects declarations of a particular kind

    - #### and

          public DeclarationFilter and(DeclarationFilter f)

      Deprecated.
      Returns a filter that selects those declarations selected by both this filter and another.
      Parameters:
        `f` - filter to be composed with this one
      Returns:
        a filter that selects those declarations selected by both this filter and another

    - #### or

          public DeclarationFilter or(DeclarationFilter f)

      Deprecated.
      Returns a filter that selects those declarations selected by either this filter or another.
      Parameters:
        `f` - filter to be composed with this one
      Returns:
        a filter that selects those declarations selected by either this filter or another

    - #### not

          public DeclarationFilter not()

      Deprecated.
      Returns a filter that selects those declarations not selected by this filter.
      Returns:
        a filter that selects those declarations not selected by this filter

    - #### matches

          public boolean matches(Declaration decl)

      Deprecated.
      Tests whether this filter matches a given declaration. The default implementation always returns `true`; subclasses should override this.
      Parameters:
        `decl` - the declaration to match
      Returns:
        `true` if this filter matches the given declaration

    - #### filter

          public <D extends Declaration> Collection<D> filter(Collection<D> decls)

      Deprecated.
      Returns the declarations matched by this filter. The result is a collection of the same type as the argument; the two-parameter version of `filter` offers control over the result type.
      Type Parameters:
        `D` - type of the declarations being filtered
      Parameters:
        `decls` - declarations being filtered
      Returns:
        the declarations matched by this filter

    - #### filter

          public <D extends Declaration> Collection<D> filter(Collection<? extends Declaration> decls,
                                                     Class<D> resType)

      Deprecated.
      Returns the declarations matched by this filter, with the result being restricted to declarations of a given kind. Similar to the simpler single-parameter version of `filter`, but the result type is specified explicitly.
      Type Parameters:
        `D` - type of the declarations being returned
      Parameters:
        `decls` - declarations being filtered
        `resType` - type of the declarations being returned -- the reflective view of `D`
      Returns:
        the declarations matched by this filter, restricted to those of the specified type

Copyright © 2004, 2019, Oracle and/or its affiliates. All rights reserved.