Polish PropertyDescriptorResolver

pull/33914/head
Moritz Halbritter 2 years ago
parent ac91cfdfbf
commit 6c44055fd4

@ -58,23 +58,22 @@ class PropertyDescriptorResolver {
if (factoryMethod != null) { if (factoryMethod != null) {
return resolveJavaBeanProperties(type, factoryMethod, members); return resolveJavaBeanProperties(type, factoryMethod, members);
} }
return resolve(ConfigurationPropertiesTypeElement.of(type, this.environment), factoryMethod, members); return resolve(ConfigurationPropertiesTypeElement.of(type, this.environment), members);
} }
private Stream<PropertyDescriptor<?>> resolve(ConfigurationPropertiesTypeElement type, private Stream<PropertyDescriptor<?>> resolve(ConfigurationPropertiesTypeElement type, TypeElementMembers members) {
ExecutableElement factoryMethod, TypeElementMembers members) {
if (type.isConstructorBindingEnabled()) { if (type.isConstructorBindingEnabled()) {
ExecutableElement constructor = type.getBindConstructor(); ExecutableElement constructor = type.getBindConstructor();
if (constructor != null) { if (constructor != null) {
return resolveConstructorProperties(type.getType(), factoryMethod, members, constructor); return resolveConstructorProperties(type.getType(), members, constructor);
} }
return Stream.empty(); return Stream.empty();
} }
return resolveJavaBeanProperties(type.getType(), factoryMethod, members); return resolveJavaBeanProperties(type.getType(), null, members);
} }
Stream<PropertyDescriptor<?>> resolveConstructorProperties(TypeElement type, ExecutableElement factoryMethod, Stream<PropertyDescriptor<?>> resolveConstructorProperties(TypeElement type, TypeElementMembers members,
TypeElementMembers members, ExecutableElement constructor) { ExecutableElement constructor) {
Map<String, PropertyDescriptor<?>> candidates = new LinkedHashMap<>(); Map<String, PropertyDescriptor<?>> candidates = new LinkedHashMap<>();
constructor.getParameters().forEach((parameter) -> { constructor.getParameters().forEach((parameter) -> {
String name = getParameterName(parameter); String name = getParameterName(parameter);
@ -82,8 +81,8 @@ class PropertyDescriptorResolver {
ExecutableElement getter = members.getPublicGetter(name, propertyType); ExecutableElement getter = members.getPublicGetter(name, propertyType);
ExecutableElement setter = members.getPublicSetter(name, propertyType); ExecutableElement setter = members.getPublicSetter(name, propertyType);
VariableElement field = members.getFields().get(name); VariableElement field = members.getFields().get(name);
register(candidates, new ConstructorParameterPropertyDescriptor(type, factoryMethod, parameter, name, register(candidates, new ConstructorParameterPropertyDescriptor(type, null, parameter, name, propertyType,
propertyType, field, getter, setter)); field, getter, setter));
}); });
return candidates.values().stream(); return candidates.values().stream();
} }

Loading…
Cancel
Save