Package org.springframework.aot.hint

# 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 Summary

Constructors
Constructor
Description
`ReflectionHints()`

## Method Summary

Modifier and Type
Method
Description
`TypeHint`
`getTypeHint(Class<?> type)`
Return the reflection hints for the specified type.
`TypeHint`
`getTypeHint(TypeReference type)`
Return the reflection hints for the type defined by the specified `TypeReference`.
`ReflectionHints`
`registerConstructor(Constructor<?> constructor, ExecutableMode mode)`
Register the need for reflection on the specified `Constructor`, using the specified `ExecutableMode`.
`ReflectionHints`
`registerField(Field field)`
Register the need for reflective field access on the specified `Field`.
`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.
`ReflectionHints`
`registerMethod(Method method, ExecutableMode mode)`
Register the need for reflection on the specified `Method`, using the specified `ExecutableMode`.
`ReflectionHints`
`registerType(Class<?> type, Consumer<TypeHint.Builder> typeHint)`
Register or customize reflection hints for the specified type.
`ReflectionHints`
`registerType(Class<?> type, MemberCategory... memberCategories)`
Register or customize reflection hints for the specified type using the specified `MemberCategories`.
`ReflectionHints`
`registerType(TypeReference type, Consumer<TypeHint.Builder> typeHint)`
Register or customize reflection hints for the type defined by the specified `TypeReference`.
`ReflectionHints`
`registerType(TypeReference type, MemberCategory... memberCategories)`
Register or customize reflection hints for the specified type using the specified `MemberCategories`.
`ReflectionHints`
`registerTypeIfPresent(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`.
`ReflectionHints`
`registerTypeIfPresent(ClassLoader classLoader, String typeName, MemberCategory... memberCategories)`
Register or customize reflection hints for the specified type if it is available using the specified `ClassLoader`.
`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`.
`Stream<TypeHint>`
`typeHints()`
Return the types that require reflection.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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(TypeReference, MemberCategory...)`

### 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(Class, MemberCategory...)`

### 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(ClassLoader, String, MemberCategory...)`

### 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
Since:
  6.2

### registerField

public ReflectionHints registerField(Field field)
Register the need for reflective field access on the specified `Field`.

Parameters:
  `field` - the field that requires reflective access
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