Migrate hint registration to shortcuts

Migrate code to make use of the `MemberCategory` and `FieldMode`
shortcuts.

See gh-29011
This commit is contained in:
Phillip Webb
2022-09-01 16:30:25 -07:00
parent bc0bf1fac3
commit 505da5c602
17 changed files with 147 additions and 198 deletions

View File

@@ -36,7 +36,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,8 +46,6 @@ import org.springframework.aot.generate.GeneratedMethod;
import org.springframework.aot.generate.GenerationContext;
import org.springframework.aot.generate.MethodReference;
import org.springframework.aot.hint.ExecutableMode;
import org.springframework.aot.hint.FieldHint;
import org.springframework.aot.hint.FieldMode;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
@@ -914,10 +911,6 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
private static final String INSTANCE_PARAMETER = "instance";
private static final Consumer<FieldHint.Builder> ALLOW_WRITE = builder -> builder
.withMode(FieldMode.WRITE);
private final Class<?> target;
private final Collection<AutowiredElement> autowiredElements;
@@ -987,7 +980,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
private CodeBlock generateMethodStatementForField(Field field, boolean required,
RuntimeHints hints) {
hints.reflection().registerField(field, ALLOW_WRITE);
hints.reflection().registerField(field);
CodeBlock resolver = CodeBlock.of("$T.$L($S)",
AutowiredFieldValueResolver.class,
(!required) ? "forField" : "forRequiredField", field.getName());