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 and do use the argument 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 but unsafe for concurrent access. A returned set
has the same iteration order as the argument set to a method.
If iterables and 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 inelements
.static Set<ExecutableElement>
constructorsIn(Set<? extends Element> elements)
Returns a set of constructors inelements
.static List<ModuleElement.ExportsDirective>
exportsIn(Iterable<? extends ModuleElement.Directive> directives)
Returns a list ofexports
directives indirectives
.static List<VariableElement>
fieldsIn(Iterable<? extends Element> elements)
Returns a list of fields inelements
.static Set<VariableElement>
fieldsIn(Set<? extends Element> elements)
Returns a set of fields inelements
.static List<ExecutableElement>
methodsIn(Iterable<? extends Element> elements)
Returns a list of methods inelements
.static Set<ExecutableElement>
methodsIn(Set<? extends Element> elements)
Returns a set of methods inelements
.static List<ModuleElement>
modulesIn(Iterable<? extends Element> elements)
Returns a list of modules inelements
.static Set<ModuleElement>
modulesIn(Set<? extends Element> elements)
Returns a set of modules inelements
.static List<ModuleElement.OpensDirective>
opensIn(Iterable<? extends ModuleElement.Directive> directives)
Returns a list ofopens
directives indirectives
.static List<PackageElement>
packagesIn(Iterable<? extends Element> elements)
Returns a list of packages inelements
.static Set<PackageElement>
packagesIn(Set<? extends Element> elements)
Returns a set of packages inelements
.static List<ModuleElement.ProvidesDirective>
providesIn(Iterable<? extends ModuleElement.Directive> directives)
Returns a list ofprovides
directives indirectives
.static List<RecordComponentElement>
recordComponentsIn(Iterable<? extends Element> elements)
Associated with records, a preview feature of the Java language.
Returns a list of record components inelements
.static Set<RecordComponentElement>
recordComponentsIn(Set<? extends Element> elements)
Associated with records, a preview feature of the Java language.
Returns a set of record components inelements
.static List<ModuleElement.RequiresDirective>
requiresIn(Iterable<? extends ModuleElement.Directive> directives)
Returns a list ofrequires
directives indirectives
.static List<TypeElement>
typesIn(Iterable<? extends Element> elements)
Returns a list of types inelements
.static Set<TypeElement>
typesIn(Set<? extends Element> elements)
Returns a set of types inelements
.static List<ModuleElement.UsesDirective>
usesIn(Iterable<? extends ModuleElement.Directive> directives)
Returns a list ofuses
directives indirectives
.
-
Method Details
-
fieldsIn
Returns a list of fields inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of fields in
elements
-
fieldsIn
Returns a set of fields inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of fields in
elements
-
recordComponentsIn
public static List<RecordComponentElement> recordComponentsIn(Iterable<? extends Element> elements)This method is associated with records, a preview feature of the Java language. Preview features may be removed in a future release, or upgraded to permanent features of the Java language.
Returns a list of record components inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of record components in
elements
- Since:
- 14
-
recordComponentsIn
This method is associated with records, a preview feature of the Java language. Preview features may be removed in a future release, or upgraded to permanent features of the Java language.
Returns a set of record components inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of record components in
elements
- Since:
- 14
-
constructorsIn
Returns a list of constructors inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of constructors in
elements
-
constructorsIn
Returns a set of constructors inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of constructors in
elements
-
methodsIn
Returns a list of methods inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of methods in
elements
-
methodsIn
Returns a set of methods inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of methods in
elements
-
typesIn
Returns a list of types inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of types in
elements
-
typesIn
Returns a set of types inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of types in
elements
-
packagesIn
Returns a list of packages inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of packages in
elements
-
packagesIn
Returns a set of packages inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a set of packages in
elements
-
modulesIn
Returns a list of modules inelements
.- Parameters:
elements
- the elements to filter- Returns:
- a list of modules in
elements
- Since:
- 9
-
modulesIn
Returns a set of modules inelements
.- 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 ofexports
directives indirectives
.- Parameters:
directives
- the directives to filter- Returns:
- a list of
exports
directives indirectives
- Since:
- 9
-
opensIn
public static List<ModuleElement.OpensDirective> opensIn(Iterable<? extends ModuleElement.Directive> directives)Returns a list ofopens
directives indirectives
.- Parameters:
directives
- the directives to filter- Returns:
- a list of
opens
directives indirectives
- Since:
- 9
-
providesIn
public static List<ModuleElement.ProvidesDirective> providesIn(Iterable<? extends ModuleElement.Directive> directives)Returns a list ofprovides
directives indirectives
.- Parameters:
directives
- the directives to filter- Returns:
- a list of
provides
directives indirectives
- Since:
- 9
-
requiresIn
public static List<ModuleElement.RequiresDirective> requiresIn(Iterable<? extends ModuleElement.Directive> directives)Returns a list ofrequires
directives indirectives
.- Parameters:
directives
- the directives to filter- Returns:
- a list of
requires
directives indirectives
- Since:
- 9
-
usesIn
public static List<ModuleElement.UsesDirective> usesIn(Iterable<? extends ModuleElement.Directive> directives)Returns a list ofuses
directives indirectives
.- Parameters:
directives
- the directives to filter- Returns:
- a list of
uses
directives indirectives
- Since:
- 9
-