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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ElementQuery.Result<T extends Element>
Result interface when building a query.
-
Field Summary
Fields Modifier and Type Field Description static ElementQuery<FieldElement>
ALL_FIELDS
Constant to retrieve all fields.static ElementQuery<ClassElement>
ALL_INNER_CLASSES
Constant to retrieve inner classes.static ElementQuery<MethodElement>
ALL_METHODS
Constant to retrieve all methods.static ElementQuery<ConstructorElement>
CONSTRUCTORS
Constant to retrieve instance constructors, not including those of the parent class.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ElementQuery<T>
annotated(java.util.function.Predicate<io.micronaut.core.annotation.AnnotationMetadata> predicate)
Allows filtering elements by annotation.ElementQuery<T>
filter(java.util.function.Predicate<T> predicate)
A final filter that allows access to the materialized Element.ElementQuery<T>
includeEnumConstants()
Indicates to include enum constants, only applicable for fields query.ElementQuery<T>
includeHiddenElements()
Indicates to include hidden methods/fields, only applicable for methods/fields query.ElementQuery<T>
includeOverriddenMethods()
Indicates to include overridden methods, only applicable for methods query.ElementQuery<T>
modifiers(java.util.function.Predicate<java.util.Set<ElementModifier>> predicate)
Allows filtering by modifiers.default ElementQuery<T>
named(java.lang.String name)
Allows filtering elements by name.ElementQuery<T>
named(java.util.function.Predicate<java.lang.String> predicate)
Allows filtering elements by name.static <T1 extends Element>
ElementQuery<T1>of(java.lang.Class<T1> elementType)
Create a newElementQuery
for the given element type.ElementQuery<T>
onlyAbstract()
Indicates that only abstract members should be returned.ElementQuery<T>
onlyAccessible()
Indicates that only accessible members should be returned.ElementQuery<T>
onlyAccessible(ClassElement fromType)
Indicates that only accessible members from the given type should be returned.ElementQuery<T>
onlyConcrete()
Indicates that only concrete members should be returned.ElementQuery<T>
onlyDeclared()
Indicates that only declared members should be returned and not members from parent classes.ElementQuery<T>
onlyInjected()
Search for methods that are injection points.ElementQuery<T>
onlyInstance()
Indicates to return only instance (non-static methods).ElementQuery.Result<T>
result()
Build the query result.ElementQuery<T>
typed(java.util.function.Predicate<ClassElement> predicate)
Allows filtering elements by type.
-
-
-
Field Detail
-
ALL_INNER_CLASSES
static final ElementQuery<ClassElement> ALL_INNER_CLASSES
Constant to retrieve inner classes.- Since:
- 3.1.0
-
ALL_FIELDS
static final ElementQuery<FieldElement> ALL_FIELDS
Constant to retrieve all fields.
-
ALL_METHODS
static final ElementQuery<MethodElement> ALL_METHODS
Constant to retrieve all methods.
-
CONSTRUCTORS
static final ElementQuery<ConstructorElement> CONSTRUCTORS
Constant to retrieve instance constructors, not including those of the parent class.
-
-
Method Detail
-
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
@NonNull ElementQuery<T> onlyAccessible(ClassElement fromType)
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
-
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
@NonNull ElementQuery<T> named(@NonNull java.util.function.Predicate<java.lang.String> predicate)
Allows filtering elements by name.- Parameters:
predicate
- The predicate to use. Should return true to include the element.- Returns:
- This query
-
named
@NonNull default ElementQuery<T> named(@NonNull java.lang.String name)
Allows filtering elements by name.- Parameters:
name
- The name to filter by- Returns:
- This query
- Since:
- 3.5.2
-
typed
@NonNull ElementQuery<T> typed(@NonNull java.util.function.Predicate<ClassElement> predicate)
Allows filtering elements by type. ForMethodElement
instances this is based on the return type.- Parameters:
predicate
- The predicate to use. Should return true to include the element.- Returns:
- This query
-
annotated
@NonNull ElementQuery<T> annotated(@NonNull java.util.function.Predicate<io.micronaut.core.annotation.AnnotationMetadata> predicate)
Allows filtering elements by annotation.- Parameters:
predicate
- The predicate to use. Should return true to include the element.- Returns:
- This query
-
modifiers
@NonNull ElementQuery<T> modifiers(@NonNull java.util.function.Predicate<java.util.Set<ElementModifier>> predicate)
Allows filtering by modifiers.- Parameters:
predicate
- The predicate to use. Should return true to include the element.- Returns:
- This query
-
filter
@NonNull ElementQuery<T> filter(@NonNull java.util.function.Predicate<T> predicate)
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
@NonNull static <T1 extends Element> ElementQuery<T1> of(@NonNull java.lang.Class<T1> elementType)
Create a newElementQuery
for the given element type.- Type Parameters:
T1
- The element generic type- Parameters:
elementType
- The element type- Returns:
- The query
-
-