Top Description Fields Constructors Methods
javax.lang.model.util

public Class ElementFilter

extends Object
Class Inheritance
Imports
java.util.Collections, .List, .Set, .EnumSet, .ArrayList, .LinkedHashSet, javax.lang.model.element.*, .ModuleElement.Directive, .ModuleElement.DirectiveKind, .ModuleElement.ExportsDirective, .ModuleElement.OpensDirective, .ModuleElement.ProvidesDirective, .ModuleElement.RequiresDirective, .ModuleElement.UsesDirective

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

Field Summary

Modifier and TypeField and Description
private static final Set<ElementKind>
private static final Set<ElementKind>
private static final Set<ElementKind>
private static final Set<ElementKind>
private static final Set<ElementKind>
private static final Set<ElementKind>
private static final Set<ElementKind>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<ExecutableElement>

Returns:

a list of constructors in elements
constructorsIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of constructors in elements.

public static Set<ExecutableElement>

Returns:

a set of constructors in elements
constructorsIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of constructors in elements.

public static List<ModuleElement.ExportsDirective>

Returns:

a list of exports directives in directives
exportsIn
(Iterable<? extends ModuleElement.Directive>
the directives to filter
directives
)

Returns a list of exports directives in directives.

public static List<VariableElement>

Returns:

a list of fields in elements
fieldsIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of fields in elements.

public static Set<VariableElement>

Returns:

a set of fields in elements
fieldsIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of fields in elements.

private static <E extends Element> List<E>
listFilter(Iterable<? extends Element> elements, Set<ElementKind> targetKinds, Class<E> clazz)

private static <D extends ModuleElement.Directive> List<D>
listFilter(Iterable<? extends ModuleElement.Directive> directives, ModuleElement.DirectiveKind directiveKind, Class<D> clazz)

public static List<ExecutableElement>

Returns:

a list of methods in elements
methodsIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of methods in elements.

public static Set<ExecutableElement>

Returns:

a set of methods in elements
methodsIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of methods in elements.

public static List<ModuleElement>

Returns:

a list of modules in elements
modulesIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of modules in elements.

public static Set<ModuleElement>

Returns:

a set of modules in elements
modulesIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of modules in elements.

public static List<ModuleElement.OpensDirective>

Returns:

a list of opens directives in directives
opensIn
(Iterable<? extends ModuleElement.Directive>
the directives to filter
directives
)

Returns a list of opens directives in directives.

public static List<PackageElement>

Returns:

a list of packages in elements
packagesIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of packages in elements.

public static Set<PackageElement>

Returns:

a set of packages in elements
packagesIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of packages in elements.

public static List<ModuleElement.ProvidesDirective>

Returns:

a list of provides directives in directives
providesIn
(Iterable<? extends ModuleElement.Directive>
the directives to filter
directives
)

Returns a list of provides directives in directives.

public static List<RecordComponentElement>

Returns:

a list of record components in elements
recordComponentsIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of record components in elements.

public static Set<RecordComponentElement>

Returns:

a set of record components in elements
recordComponentsIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of record components in elements.

public static List<ModuleElement.RequiresDirective>

Returns:

a list of requires directives in directives
requiresIn
(Iterable<? extends ModuleElement.Directive>
the directives to filter
directives
)

Returns a list of requires directives in directives.

private static <E extends Element> Set<E>
setFilter(Set<? extends Element> elements, Set<ElementKind> targetKinds, Class<E> clazz)

public static List<TypeElement>

Returns:

a list of classes and interfaces in elements
typesIn
(Iterable<? extends Element>
the elements to filter
elements
)

Returns a list of classes and interfaces in elements.

public static Set<TypeElement>

Returns:

a set of types in elements
typesIn
(Set<? extends Element>
the elements to filter
elements
)

Returns a set of types in elements.

public static List<ModuleElement.UsesDirective>

Returns:

a list of uses directives in directives
usesIn
(Iterable<? extends ModuleElement.Directive>
the directives to filter
directives
)

Returns a list of uses directives in directives.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONSTRUCTOR_KINDback to summary
private static final Set<ElementKind> CONSTRUCTOR_KIND
FIELD_KINDSback to summary
private static final Set<ElementKind> FIELD_KINDS
METHOD_KINDback to summary
private static final Set<ElementKind> METHOD_KIND
MODULE_KINDback to summary
private static final Set<ElementKind> MODULE_KIND
PACKAGE_KINDback to summary
private static final Set<ElementKind> PACKAGE_KIND
RECORD_COMPONENT_KINDback to summary
private static final Set<ElementKind> RECORD_COMPONENT_KIND
TYPE_KINDSback to summary
private static final Set<ElementKind> TYPE_KINDS

Constructor Detail

ElementFilterback to summary
private ElementFilter()

Method Detail

constructorsInback to summary
public static List<ExecutableElement> constructorsIn(Iterable<? extends Element> elements)

Returns a list of constructors in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<ExecutableElement>

a list of constructors in elements

constructorsInback to summary
public static Set<ExecutableElement> constructorsIn(Set<? extends Element> elements)

Returns a set of constructors in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<ExecutableElement>

a set of constructors in elements

exportsInback to summary
public static List<ModuleElement.ExportsDirective> exportsIn(Iterable<? extends ModuleElement.Directive> directives)

Returns a list of exports directives in directives.

Parameters
directives:Iterable<? extends ModuleElement.Directive>

the directives to filter

Returns:List<ModuleElement.ExportsDirective>

a list of exports directives in directives

Since
9
fieldsInback to summary
public static List<VariableElement> fieldsIn(Iterable<? extends Element> elements)

Returns a list of fields in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<VariableElement>

a list of fields in elements

fieldsInback to summary
public static Set<VariableElement> fieldsIn(Set<? extends Element> elements)

Returns a set of fields in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<VariableElement>

a set of fields in elements

listFilterback to summary
private static <E extends Element> List<E> listFilter(Iterable<? extends Element> elements, Set<ElementKind> targetKinds, Class<E> clazz)
listFilterback to summary
private static <D extends ModuleElement.Directive> List<D> listFilter(Iterable<? extends ModuleElement.Directive> directives, ModuleElement.DirectiveKind directiveKind, Class<D> clazz)
methodsInback to summary
public static List<ExecutableElement> methodsIn(Iterable<? extends Element> elements)

Returns a list of methods in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<ExecutableElement>

a list of methods in elements

methodsInback to summary
public static Set<ExecutableElement> methodsIn(Set<? extends Element> elements)

Returns a set of methods in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<ExecutableElement>

a set of methods in elements

modulesInback to summary
public static List<ModuleElement> modulesIn(Iterable<? extends Element> elements)

Returns a list of modules in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<ModuleElement>

a list of modules in elements

Since
9
modulesInback to summary
public static Set<ModuleElement> modulesIn(Set<? extends Element> elements)

Returns a set of modules in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<ModuleElement>

a set of modules in elements

Since
9
opensInback to summary
public static List<ModuleElement.OpensDirective> opensIn(Iterable<? extends ModuleElement.Directive> directives)

Returns a list of opens directives in directives.

Parameters
directives:Iterable<? extends ModuleElement.Directive>

the directives to filter

Returns:List<ModuleElement.OpensDirective>

a list of opens directives in directives

Since
9
packagesInback to summary
public static List<PackageElement> packagesIn(Iterable<? extends Element> elements)

Returns a list of packages in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<PackageElement>

a list of packages in elements

packagesInback to summary
public static Set<PackageElement> packagesIn(Set<? extends Element> elements)

Returns a set of packages in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<PackageElement>

a set of packages in elements

providesInback to summary
public static List<ModuleElement.ProvidesDirective> providesIn(Iterable<? extends ModuleElement.Directive> directives)

Returns a list of provides directives in directives.

Parameters
directives:Iterable<? extends ModuleElement.Directive>

the directives to filter

Returns:List<ModuleElement.ProvidesDirective>

a list of provides directives in directives

Since
9
recordComponentsInback to summary
public static List<RecordComponentElement> recordComponentsIn(Iterable<? extends Element> elements)

Returns a list of record components in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<RecordComponentElement>

a list of record components in elements

Since
16
recordComponentsInback to summary
public static Set<RecordComponentElement> recordComponentsIn(Set<? extends Element> elements)

Returns a set of record components in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<RecordComponentElement>

a set of record components in elements

Since
16
requiresInback to summary
public static List<ModuleElement.RequiresDirective> requiresIn(Iterable<? extends ModuleElement.Directive> directives)

Returns a list of requires directives in directives.

Parameters
directives:Iterable<? extends ModuleElement.Directive>

the directives to filter

Returns:List<ModuleElement.RequiresDirective>

a list of requires directives in directives

Since
9
setFilterback to summary
private static <E extends Element> Set<E> setFilter(Set<? extends Element> elements, Set<ElementKind> targetKinds, Class<E> clazz)
typesInback to summary
public static List<TypeElement> typesIn(Iterable<? extends Element> elements)

Returns a list of classes and interfaces in elements.

Parameters
elements:Iterable<? extends Element>

the elements to filter

Returns:List<TypeElement>

a list of classes and interfaces in elements

typesInback to summary
public static Set<TypeElement> typesIn(Set<? extends Element> elements)

Returns a set of types in elements.

Parameters
elements:Set<? extends Element>

the elements to filter

Returns:Set<TypeElement>

a set of types in elements

usesInback to summary
public static List<ModuleElement.UsesDirective> usesIn(Iterable<? extends ModuleElement.Directive> directives)

Returns a list of uses directives in directives.

Parameters
directives:Iterable<? extends ModuleElement.Directive>

the directives to filter

Returns:List<ModuleElement.UsesDirective>

a list of uses directives in directives

Since
9