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
  • 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
    • 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
    • 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
    • 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
    • registerField

      public ReflectionHints registerField(Field field, Consumer<FieldHint.Builder> fieldHint)
      Register the need for reflection on the specified Field.
      Parameters:
      field - the field that requires reflection
      fieldHint - a builder to further customize the hints of this field
      Returns:
      this, to facilitate method chaining
    • registerField

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

      public ReflectionHints registerConstructor(Constructor<?> constructor, Consumer<ExecutableHint.Builder> constructorHint)
      Register the need for reflection on the specified Constructor.
      Parameters:
      constructor - the constructor that requires reflection
      constructorHint - a builder to further customize the hints of this constructor
      Returns:
      this, to facilitate method chaining
    • registerConstructor

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

      public ReflectionHints registerMethod(Method method, Consumer<ExecutableHint.Builder> methodHint)
      Register the need for reflection on the specified Method.
      Parameters:
      method - the method that requires reflection
      methodHint - a builder to further customize the hints of this method
      Returns:
      this, to facilitate method chaining
    • registerMethod

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