Package io.micronaut.inject.ast
Interface ElementQuery<T extends Element>
- Type Parameters:
T- The element kind
public interface ElementQuery<T extends Element>
An interface for querying the AST for elements.
- Since:
- 2.3.0
- Author:
- graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceElementQuery.Result<T extends Element>Result interface when building a query. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ElementQuery<MemberElement> Constant to retrieve all methods and fields.static final ElementQuery<FieldElement> Constant to retrieve all fields.static final ElementQuery<ClassElement> Constant to retrieve inner classes.static final ElementQuery<MethodElement> Constant to retrieve all methods.static final ElementQuery<ConstructorElement> Constant to retrieve instance constructors, not including those of the parent class. -
Method Summary
Modifier and TypeMethodDescription@NonNull ElementQuery<T> annotated(@NonNull Predicate<AnnotationMetadata> predicate) Allows filtering elements by annotation.Indicates to exclude any property elements (read write methods and a field).@NonNull ElementQuery<T> A final filter that allows access to the materialized Element.Indicates to include enum constants, only applicable for fields query.Indicates to include hidden methods/fields, only applicable for methods/fields query.Indicates to include overridden methods, only applicable for methods query.@NonNull ElementQuery<T> modifiers(@NonNull Predicate<Set<ElementModifier>> predicate) Allows filtering by modifiers.default @NonNull ElementQuery<T> Allows filtering elements by name.@NonNull ElementQuery<T> Allows filtering elements by name.static <T1 extends Element>
@NonNull ElementQuery<T1> Create a newElementQueryfor the given element type.@NonNull ElementQuery<T> Indicates that only abstract members should be returned.@NonNull ElementQuery<T> Indicates that only accessible members should be returned.@NonNull ElementQuery<T> onlyAccessible(ClassElement fromType) Indicates that only accessible members from the given type should be returned.@NonNull ElementQuery<T> Indicates that only concrete members should be returned.@NonNull ElementQuery<T> Indicates that only declared members should be returned and not members from parent classes.Search for methods that are injection points.Indicates to return only instance (non-static methods).Indicates to return only static methods/fields.@NonNull ElementQuery.Result<T> result()Build the query result.@NonNull ElementQuery<T> typed(@NonNull Predicate<ClassElement> predicate) Allows filtering elements by type.
-
Field Details
-
ALL_INNER_CLASSES
Constant to retrieve inner classes.- Since:
- 3.1.0
-
ALL_FIELDS
Constant to retrieve all fields. -
ALL_METHODS
Constant to retrieve all methods. -
ALL_FIELD_AND_METHODS
Constant to retrieve all methods and fields.- Since:
- 4.0.0
-
CONSTRUCTORS
Constant to retrieve instance constructors, not including those of the parent class.
-
-
Method Details
-
onlyDeclared
@NonNull ElementQuery<T> onlyDeclared()Indicates that only declared members should be returned and not members from parent classes.- Returns:
- This query
-
onlyInjected
ElementQuery<T> onlyInjected()Search for methods that are injection points.- Returns:
- This query
-
onlyConcrete
@NonNull ElementQuery<T> onlyConcrete()Indicates that only concrete members should be returned.- Returns:
- This query
-
onlyAbstract
@NonNull ElementQuery<T> onlyAbstract()Indicates that only abstract members should be returned.- Returns:
- This query
-
onlyAccessible
@NonNull ElementQuery<T> onlyAccessible()Indicates that only accessible members should be returned. Inaccessible members include:- package/private members that are in a different package
- private members
- synthetic members or those whose names start with the dollar symbol
- Returns:
- This query
-
onlyAccessible
Indicates that only accessible members from the given type should be returned. Inaccessible members include:- package/private members that are in a different package
- private members
- synthetic members or those whose names start with the dollar symbol
- Parameters:
fromType- The origin type- Returns:
- This query
-
onlyInstance
ElementQuery<T> onlyInstance()Indicates to return only instance (non-static methods).- Returns:
- The query
-
onlyStatic
ElementQuery<T> onlyStatic()Indicates to return only static methods/fields.- Returns:
- The query
- Since:
- 4.0.0
-
excludePropertyElements
ElementQuery<T> excludePropertyElements()Indicates to exclude any property elements (read write methods and a field).- Returns:
- The query
- Since:
- 4.0.0
-
includeEnumConstants
ElementQuery<T> includeEnumConstants()Indicates to include enum constants, only applicable for fields query.- Returns:
- The query
- Since:
- 3.4.0
-
includeOverriddenMethods
ElementQuery<T> includeOverriddenMethods()Indicates to include overridden methods, only applicable for methods query.- Returns:
- The query
- Since:
- 3.4.0
-
includeHiddenElements
ElementQuery<T> includeHiddenElements()Indicates to include hidden methods/fields, only applicable for methods/fields query.- Returns:
- The query
- Since:
- 3.4.0
-
named
Allows filtering elements by name. This method will only process native elements passing the name predicate. NOTE: Use this method only if the other elements shouldn't be touched (missing compilation information etc.). This method will skip all elements reusable cache.- Parameters:
predicate- The predicate to use. Should return true to include the element.- Returns:
- This query
-
named
Allows filtering elements by name. This method will only process native elements passing the name predicate. NOTE: Use this method only if the other elements shouldn't be touched (missing compilation information etc.). This method will skip all elements reusable cache.- Parameters:
name- The name to filter by- Returns:
- This query
- Since:
- 3.5.2
-
typed
Allows filtering elements by type. ForMethodElementinstances this is based on the return type.- Parameters:
predicate- The predicate to use. Should return true to include the element.- Returns:
- This query
-
annotated
Allows filtering elements by annotation.- Parameters:
predicate- The predicate to use. Should return true to include the element.- Returns:
- This query
-
modifiers
Allows filtering by modifiers.- Parameters:
predicate- The predicate to use. Should return true to include the element.- Returns:
- This query
-
filter
A final filter that allows access to the materialized Element. This method should be used as a last resort as it is less efficient than the other filtration methods.- Parameters:
predicate- The predicate to use. Should return true to include the element.- Returns:
- This query
-
result
@NonNull ElementQuery.Result<T> result()Build the query result.- Returns:
- The query result.
-
of
Create a newElementQueryfor the given element type.- Type Parameters:
T1- The element generic type- Parameters:
elementType- The element type- Returns:
- The query
-