Add shortcut to register an executable with a mode
See gh-29011
This commit is contained in:
@@ -158,6 +158,17 @@ public class ReflectionHints {
|
||||
typeHint -> typeHint.withConstructor(mapParameters(constructor), constructorHint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the need for reflection on the specified {@link Constructor},
|
||||
* using the specified {@link ExecutableMode}.
|
||||
* @param constructor the constructor that requires reflection
|
||||
* @param mode the requested mode
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
*/
|
||||
public ReflectionHints registerConstructor(Constructor<?> constructor, ExecutableMode mode) {
|
||||
return registerConstructor(constructor, constructorHint -> constructorHint.withMode(mode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the need for reflection on the specified {@link Constructor},
|
||||
* enabling {@link ExecutableMode#INVOKE}.
|
||||
@@ -165,7 +176,7 @@ public class ReflectionHints {
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
*/
|
||||
public ReflectionHints registerConstructor(Constructor<?> constructor) {
|
||||
return registerConstructor(constructor, constructorHint -> constructorHint.withMode(ExecutableMode.INVOKE));
|
||||
return registerConstructor(constructor, ExecutableMode.INVOKE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,6 +190,17 @@ public class ReflectionHints {
|
||||
typeHint -> typeHint.withMethod(method.getName(), mapParameters(method), methodHint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the need for reflection on the specified {@link Method},
|
||||
* using the specified {@link ExecutableMode}.
|
||||
* @param method the method that requires reflection
|
||||
* @param mode the requested mode
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
*/
|
||||
public ReflectionHints registerMethod(Method method, ExecutableMode mode) {
|
||||
return registerMethod(method, methodHint -> methodHint.withMode(mode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the need for reflection on the specified {@link Method},
|
||||
* enabling {@link ExecutableMode#INVOKE}.
|
||||
@@ -186,7 +208,7 @@ public class ReflectionHints {
|
||||
* @return {@code this}, to facilitate method chaining
|
||||
*/
|
||||
public ReflectionHints registerMethod(Method method) {
|
||||
return registerMethod(method, methodHint -> methodHint.withMode(ExecutableMode.INVOKE));
|
||||
return registerMethod(method, ExecutableMode.INVOKE);
|
||||
}
|
||||
|
||||
private List<TypeReference> mapParameters(Executable executable) {
|
||||
|
||||
Reference in New Issue
Block a user