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
    • 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. For MethodElement 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 ElementElementQuery<T1> of​(@NonNull
                                                        java.lang.Class<T1> elementType)
        Create a new ElementQuery for the given element type.
        Type Parameters:
        T1 - The element generic type
        Parameters:
        elementType - The element type
        Returns:
        The query