Polishing
This commit is contained in:
parent
7631a09405
commit
a052f9a34e
|
@ -100,8 +100,7 @@ public abstract class RuntimeHintsUtils {
|
||||||
Class<?> annotationAttribute = aliasFor.annotation();
|
Class<?> annotationAttribute = aliasFor.annotation();
|
||||||
Class<?> targetAnnotation = (annotationAttribute != Annotation.class
|
Class<?> targetAnnotation = (annotationAttribute != Annotation.class
|
||||||
? annotationAttribute : annotationType);
|
? annotationAttribute : annotationType);
|
||||||
if (!types.contains(targetAnnotation)) {
|
if (types.add(targetAnnotation)) {
|
||||||
types.add(targetAnnotation);
|
|
||||||
if (!targetAnnotation.equals(annotationType)) {
|
if (!targetAnnotation.equals(annotationType)) {
|
||||||
collectAliasedAnnotations(seen, types, targetAnnotation);
|
collectAliasedAnnotations(seen, types, targetAnnotation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.aot.hint.JdkProxyHint;
|
import org.springframework.aot.hint.JdkProxyHint;
|
||||||
import org.springframework.aot.hint.MemberCategory;
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
import org.springframework.aot.hint.ReflectionHints;
|
|
||||||
import org.springframework.aot.hint.RuntimeHints;
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.TypeHint;
|
import org.springframework.aot.hint.TypeHint;
|
||||||
import org.springframework.aot.hint.TypeReference;
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
@ -74,7 +73,8 @@ class RuntimeHintsUtilsTests {
|
||||||
RuntimeHintsUtils.registerAnnotation(this.hints, RetryInvoker.class);
|
RuntimeHintsUtils.registerAnnotation(this.hints, RetryInvoker.class);
|
||||||
assertThat(this.hints.reflection().typeHints())
|
assertThat(this.hints.reflection().typeHints())
|
||||||
.anySatisfy(annotationHint(RetryInvoker.class))
|
.anySatisfy(annotationHint(RetryInvoker.class))
|
||||||
.anySatisfy(annotationHint(SampleInvoker.class));
|
.anySatisfy(annotationHint(SampleInvoker.class))
|
||||||
|
.hasSize(2);
|
||||||
assertThat(this.hints.proxies().jdkProxies())
|
assertThat(this.hints.proxies().jdkProxies())
|
||||||
.anySatisfy(annotationProxy(RetryInvoker.class))
|
.anySatisfy(annotationProxy(RetryInvoker.class))
|
||||||
.anySatisfy(annotationProxy(SampleInvoker.class))
|
.anySatisfy(annotationProxy(SampleInvoker.class))
|
||||||
|
@ -92,8 +92,7 @@ class RuntimeHintsUtilsTests {
|
||||||
@Test
|
@Test
|
||||||
void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() {
|
void registerAnnotationTypeWhereUsedAsAMetaAnnotationRegistersHierarchy() {
|
||||||
RuntimeHintsUtils.registerAnnotation(this.hints, RetryWithEnabledFlagInvoker.class);
|
RuntimeHintsUtils.registerAnnotation(this.hints, RetryWithEnabledFlagInvoker.class);
|
||||||
ReflectionHints reflection = this.hints.reflection();
|
assertThat(this.hints.reflection().typeHints())
|
||||||
assertThat(reflection.typeHints())
|
|
||||||
.anySatisfy(annotationHint(RetryWithEnabledFlagInvoker.class))
|
.anySatisfy(annotationHint(RetryWithEnabledFlagInvoker.class))
|
||||||
.anySatisfy(annotationHint(RetryInvoker.class))
|
.anySatisfy(annotationHint(RetryInvoker.class))
|
||||||
.anySatisfy(annotationHint(SampleInvoker.class))
|
.anySatisfy(annotationHint(SampleInvoker.class))
|
||||||
|
@ -117,8 +116,7 @@ class RuntimeHintsUtilsTests {
|
||||||
|
|
||||||
private Consumer<JdkProxyHint> annotationProxy(Class<?> type) {
|
private Consumer<JdkProxyHint> annotationProxy(Class<?> type) {
|
||||||
return jdkProxyHint -> assertThat(jdkProxyHint.getProxiedInterfaces())
|
return jdkProxyHint -> assertThat(jdkProxyHint.getProxiedInterfaces())
|
||||||
.containsExactly(TypeReference.of(type),
|
.containsExactly(TypeReference.of(type), TypeReference.of(SynthesizedAnnotation.class));
|
||||||
TypeReference.of(SynthesizedAnnotation.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +152,7 @@ class RuntimeHintsUtilsTests {
|
||||||
@RetryInvoker
|
@RetryInvoker
|
||||||
@interface RetryWithEnabledFlagInvoker {
|
@interface RetryWithEnabledFlagInvoker {
|
||||||
|
|
||||||
@AliasFor(attribute = "value", annotation = RetryInvoker.class)
|
@AliasFor(annotation = RetryInvoker.class)
|
||||||
int value() default 5;
|
int value() default 5;
|
||||||
|
|
||||||
boolean enabled() default true;
|
boolean enabled() default true;
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.springframework.lang.Nullable;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link RuntimeHintsRegistrar} implementation that make web binding
|
* {@link RuntimeHintsRegistrar} implementation that makes web binding
|
||||||
* annotations at runtime.
|
* annotations available at runtime.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
|
Loading…
Reference in New Issue