Class ReflectionHints

java.lang.Object
org.springframework.aot.hint.ReflectionHints

public class ReflectionHints extends Object
Gather the need for reflection at runtime.
Since:
6.0
Author:
Stephane Nicoll, Phillip Webb, Andy Wilkinson, Sebastien Deleuze
  • Constructor Details

    • ReflectionHints

      public ReflectionHints()
  • Method Details

    • typeHints

      public Stream<TypeHint> typeHints()
      Return the types that require reflection.
      Returns:
      the type hints
    • getTypeHint

      @Nullable public TypeHint getTypeHint(TypeReference type)
      Return the reflection hints for the type defined by the specified TypeReference.
      Parameters:
      type - the type to inspect
      Returns:
      the reflection hints for this type, or null
    • getTypeHint

      @Nullable public TypeHint getTypeHint(Class<?> type)
      Return the reflection hints for the specified type.
      Parameters:
      type - the type to inspect
      Returns:
      the reflection hints for this type, or null
    • registerType

      public ReflectionHints registerType(TypeReference type, Consumer<TypeHint.Builder> typeHint)
      Register or customize reflection hints for the type defined by the specified TypeReference.
      Parameters:
      type - the type to customize
      typeHint - a builder to further customize hints for that type
      Returns:
      this, to facilitate method chaining
      See Also:
    • registerType

      public ReflectionHints registerType(TypeReference type, MemberCategory... memberCategories)
      Register or customize reflection hints for the specified type using the specified MemberCategories.
      Parameters:
      type - the type to customize
      memberCategories - the member categories to apply
      Returns:
      this, to facilitate method chaining
    • registerType

      public ReflectionHints registerType(Class<?> type, Consumer<TypeHint.Builder> typeHint)
      Register or customize reflection hints for the specified type.
      Parameters:
      type - the type to customize
      typeHint - a builder to further customize hints for that type
      Returns:
      this, to facilitate method chaining
      See Also:
    • registerType

      public ReflectionHints registerType(Class<?> type, MemberCategory... memberCategories)
      Register or customize reflection hints for the specified type using the specified MemberCategories.
      Parameters:
      type - the type to customize
      memberCategories - the member categories to apply
      Returns:
      this, to facilitate method chaining
    • registerTypeIfPresent

      public ReflectionHints registerTypeIfPresent(@Nullable ClassLoader classLoader, String typeName, Consumer<TypeHint.Builder> typeHint)
      Register or customize reflection hints for the specified type if it is available using the specified ClassLoader.
      Parameters:
      classLoader - the classloader to use to check if the type is present
      typeName - the type to customize
      typeHint - a builder to further customize hints for that type
      Returns:
      this, to facilitate method chaining
      See Also:
    • registerTypeIfPresent

      public ReflectionHints registerTypeIfPresent(@Nullable ClassLoader classLoader, String typeName, MemberCategory... memberCategories)
      Register or customize reflection hints for the specified type if it is available using the specified ClassLoader.
      Parameters:
      classLoader - the classloader to use to check if the type is present
      typeName - the type to customize
      memberCategories - the member categories to apply
      Returns:
      this, to facilitate method chaining
    • registerTypes

      public ReflectionHints registerTypes(Iterable<TypeReference> types, Consumer<TypeHint.Builder> typeHint)
      Register or customize reflection hints for the types defined by the specified list of type references. The specified typeHint consumer is invoked for each type.
      Parameters:
      types - the types to customize
      typeHint - a builder to further customize hints for each type
      Returns:
      this, to facilitate method chaining
    • registerForInterfaces

      public ReflectionHints registerForInterfaces(Class<?> type, Consumer<TypeHint.Builder> typeHint)
      Register or customize reflection hints for all the interfaces implemented by the given type and its parent classes, ignoring the common Java language interfaces. The specified typeHint consumer is invoked for each type.
      Parameters:
      type - the type to consider
      typeHint - a builder to further customize hints for each type
      Returns:
      this, to facilitate method chaining
    • registerField

      public ReflectionHints registerField(Field field)
      Register the need for reflection on the specified Field.
      Parameters:
      field - the field that requires reflection
      Returns:
      this, to facilitate method chaining
    • registerConstructor

      public ReflectionHints registerConstructor(Constructor<?> constructor, ExecutableMode mode)
      Register the need for reflection on the specified Constructor, using the specified ExecutableMode.
      Parameters:
      constructor - the constructor that requires reflection
      mode - the requested mode
      Returns:
      this, to facilitate method chaining
    • registerMethod

      public ReflectionHints registerMethod(Method method, ExecutableMode mode)
      Register the need for reflection on the specified Method, using the specified ExecutableMode.
      Parameters:
      method - the method that requires reflection
      mode - the requested mode
      Returns:
      this, to facilitate method chaining