ElementFilter (Java SE 26 & JDK 26)
Description: declaration: module: java.compiler, package: javax.lang.model.util, class: ElementFilter
Keywords: javax.lang.model.util.ElementFilter class

# Class ElementFilter

java.lang.Object
javax.lang.model.util.ElementFilter

public class ElementFilter extends Object
Filters for selecting just the elements of interest from a collection of elements. The returned sets and lists are new collections that do not use the argument collection as a backing store. The methods in this class do not make any attempts to guard against concurrent modifications of the arguments. The returned sets and lists are mutable and unsafe for concurrent access. A returned set from a method has the same iteration order as the argument set to the method.

If iterables or sets containing `null` are passed as arguments to methods in this class, a `NullPointerException` will be thrown.

Since:
  1.6

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static List<ExecutableElement>`
  `constructorsIn(Iterable<? extends Element> elements)`
  Returns a list of constructors in `elements`.
  `static Set<ExecutableElement>`
  `constructorsIn(Set<? extends Element> elements)`
  Returns a set of constructors in `elements`.
  `static List<ModuleElement.ExportsDirective>`
  `exportsIn(Iterable<? extends ModuleElement.Directive> directives)`
  Returns a list of `exports` directives in `directives`.
  `static List<VariableElement>`
  `fieldsIn(Iterable<? extends Element> elements)`
  Returns a list of fields in `elements`.
  `static Set<VariableElement>`
  `fieldsIn(Set<? extends Element> elements)`
  Returns a set of fields in `elements`.
  `static List<ExecutableElement>`
  `methodsIn(Iterable<? extends Element> elements)`
  Returns a list of methods in `elements`.
  `static Set<ExecutableElement>`
  `methodsIn(Set<? extends Element> elements)`
  Returns a set of methods in `elements`.
  `static List<ModuleElement>`
  `modulesIn(Iterable<? extends Element> elements)`
  Returns a list of modules in `elements`.
  `static Set<ModuleElement>`
  `modulesIn(Set<? extends Element> elements)`
  Returns a set of modules in `elements`.
  `static List<ModuleElement.OpensDirective>`
  `opensIn(Iterable<? extends ModuleElement.Directive> directives)`
  Returns a list of `opens` directives in `directives`.
  `static List<PackageElement>`
  `packagesIn(Iterable<? extends Element> elements)`
  Returns a list of packages in `elements`.
  `static Set<PackageElement>`
  `packagesIn(Set<? extends Element> elements)`
  Returns a set of packages in `elements`.
  `static List<ModuleElement.ProvidesDirective>`
  `providesIn(Iterable<? extends ModuleElement.Directive> directives)`
  Returns a list of `provides` directives in `directives`.
  `static List<RecordComponentElement>`
  `recordComponentsIn(Iterable<? extends Element> elements)`
  Returns a list of record components in `elements`.
  `static Set<RecordComponentElement>`
  `recordComponentsIn(Set<? extends Element> elements)`
  Returns a set of record components in `elements`.
  `static List<ModuleElement.RequiresDirective>`
  `requiresIn(Iterable<? extends ModuleElement.Directive> directives)`
  Returns a list of `requires` directives in `directives`.
  `static List<TypeElement>`
  `typesIn(Iterable<? extends Element> elements)`
  Returns a list of classes and interfaces in `elements`.
  `static Set<TypeElement>`
  `typesIn(Set<? extends Element> elements)`
  Returns a set of classes and interfaces in `elements`.
  `static List<ModuleElement.UsesDirective>`
  `usesIn(Iterable<? extends ModuleElement.Directive> directives)`
  Returns a list of `uses` directives in `directives`.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Method Details

  - ### fieldsIn

    public static List<VariableElement> fieldsIn(Iterable<? extends Element> elements)
    Returns a list of fields in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of fields in `elements`

  - ### fieldsIn

    public static Set<VariableElement> fieldsIn(Set<? extends Element> elements)
    Returns a set of fields in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of fields in `elements`

  - ### recordComponentsIn

    public static List<RecordComponentElement> recordComponentsIn(Iterable<? extends Element> elements)
    Returns a list of record components in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of record components in `elements`
    Since:
      16

  - ### recordComponentsIn

    public static Set<RecordComponentElement> recordComponentsIn(Set<? extends Element> elements)
    Returns a set of record components in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of record components in `elements`
    Since:
      16

  - ### constructorsIn

    public static List<ExecutableElement> constructorsIn(Iterable<? extends Element> elements)
    Returns a list of constructors in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of constructors in `elements`

  - ### constructorsIn

    public static Set<ExecutableElement> constructorsIn(Set<? extends Element> elements)
    Returns a set of constructors in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of constructors in `elements`

  - ### methodsIn

    public static List<ExecutableElement> methodsIn(Iterable<? extends Element> elements)
    Returns a list of methods in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of methods in `elements`

  - ### methodsIn

    public static Set<ExecutableElement> methodsIn(Set<? extends Element> elements)
    Returns a set of methods in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of methods in `elements`

  - ### typesIn

    public static List<TypeElement> typesIn(Iterable<? extends Element> elements)
    Returns a list of classes and interfaces in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of classes and interfaces in `elements`

  - ### typesIn

    public static Set<TypeElement> typesIn(Set<? extends Element> elements)
    Returns a set of classes and interfaces in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of classes and interfaces in `elements`

  - ### packagesIn

    public static List<PackageElement> packagesIn(Iterable<? extends Element> elements)
    Returns a list of packages in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of packages in `elements`

  - ### packagesIn

    public static Set<PackageElement> packagesIn(Set<? extends Element> elements)
    Returns a set of packages in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of packages in `elements`

  - ### modulesIn

    public static List<ModuleElement> modulesIn(Iterable<? extends Element> elements)
    Returns a list of modules in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a list of modules in `elements`
    Since:
      9

  - ### modulesIn

    public static Set<ModuleElement> modulesIn(Set<? extends Element> elements)
    Returns a set of modules in `elements`.
    Parameters:
      `elements` - the elements to filter
    Returns:
      a set of modules in `elements`
    Since:
      9

  - ### exportsIn

    public static List<ModuleElement.ExportsDirective> exportsIn(Iterable<? extends ModuleElement.Directive> directives)
    Returns a list of `exports` directives in `directives`.
    Parameters:
      `directives` - the directives to filter
    Returns:
      a list of `exports` directives in `directives`
    Since:
      9

  - ### opensIn

    public static List<ModuleElement.OpensDirective> opensIn(Iterable<? extends ModuleElement.Directive> directives)
    Returns a list of `opens` directives in `directives`.
    Parameters:
      `directives` - the directives to filter
    Returns:
      a list of `opens` directives in `directives`
    Since:
      9

  - ### providesIn

    public static List<ModuleElement.ProvidesDirective> providesIn(Iterable<? extends ModuleElement.Directive> directives)
    Returns a list of `provides` directives in `directives`.
    Parameters:
      `directives` - the directives to filter
    Returns:
      a list of `provides` directives in `directives`
    Since:
      9

  - ### requiresIn

    public static List<ModuleElement.RequiresDirective> requiresIn(Iterable<? extends ModuleElement.Directive> directives)
    Returns a list of `requires` directives in `directives`.
    Parameters:
      `directives` - the directives to filter
    Returns:
      a list of `requires` directives in `directives`
    Since:
      9

  - ### usesIn

    public static List<ModuleElement.UsesDirective> usesIn(Iterable<? extends ModuleElement.Directive> directives)
    Returns a list of `uses` directives in `directives`.
    Parameters:
      `directives` - the directives to filter
    Returns:
      a list of `uses` directives in `directives`
    Since:
      9