Add shortcut method to register multiple types hints
Closes gh-28339
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.aot.hint;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -87,6 +88,20 @@ class ReflectionHintsTests {
|
||||
typeWithMemberCategories(Integer.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerTypesApplyTheSameHints() {
|
||||
this.reflectionHints.registerTypes(Stream.of(Integer.class, String.class, Double.class)
|
||||
.map(TypeReference::of).toList(), hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
assertThat(this.reflectionHints.typeHints())
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(Integer.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(String.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.anySatisfy(
|
||||
typeWithMemberCategories(Double.class, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
|
||||
.hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerField() {
|
||||
Field field = ReflectionUtils.findField(TestType.class, "field");
|
||||
|
||||
Reference in New Issue
Block a user