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
  • Field Details

  • Method Details

    • onlyDeclared

      @NonNull @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 @NonNull ElementQuery<T> onlyConcrete()
      Indicates that only concrete members should be returned.
      Returns:
      This query
    • onlyAbstract

      @NonNull @NonNull ElementQuery<T> onlyAbstract()
      Indicates that only abstract members should be returned.
      Returns:
      This query
    • onlyAccessible

      @NonNull @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 @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
    • 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.
      Parameters:
      predicate - The predicate to use. Should return true to include the element.
      Returns:
      This query
    • named

      Allows filtering elements by name.
      Parameters:
      name - The name to filter by
      Returns:
      This query
      Since:
      3.5.2
    • typed

      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

      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

      Build the query result.
      Returns:
      The query result.
    • of

      @NonNull static <T1 extends Element> @NonNull ElementQuery<T1> of(@NonNull @NonNull 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