Reintroduce explicit local variable types.
We now reinstate local variable types instead of var as general var usage removes contextual detail that cannot be omitted generally. See #2465
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.config;
|
||||
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
@@ -60,8 +61,8 @@ public class BeanComponentDefinitionBuilder {
|
||||
|
||||
Assert.notNull(builder, "Builder must not be null!");
|
||||
|
||||
var definition = builder.getRawBeanDefinition();
|
||||
var name = BeanDefinitionReaderUtils.generateBeanName(definition, context.getRegistry(), context.isNested());
|
||||
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
|
||||
String name = BeanDefinitionReaderUtils.generateBeanName(definition, context.getRegistry(), context.isNested());
|
||||
|
||||
return getComponent(builder, name);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class BeanComponentDefinitionBuilder {
|
||||
|
||||
Assert.hasText(fallback, "Fallback component id must not be null or empty!");
|
||||
|
||||
var id = defaultSource.getAttribute("id");
|
||||
String id = defaultSource.getAttribute("id");
|
||||
return getComponent(builder, StringUtils.hasText(id) ? id : fallback);
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ public class BeanComponentDefinitionBuilder {
|
||||
Assert.notNull(builder, "Builder must not be null!");
|
||||
Assert.hasText(name, "Name of bean must not be null or empty!");
|
||||
|
||||
var definition = builder.getRawBeanDefinition();
|
||||
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
|
||||
definition.setSource(context.extractSource(rawSource));
|
||||
|
||||
return new BeanComponentDefinition(definition, name);
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface ConfigurationUtils {
|
||||
|
||||
Assert.notNull(context, "XmlReaderContext must not be null!");
|
||||
|
||||
var resourceLoader = context.getResourceLoader();
|
||||
ResourceLoader resourceLoader = context.getResourceLoader();
|
||||
|
||||
if (resourceLoader == null) {
|
||||
throw new IllegalArgumentException("Could not obtain ResourceLoader from XmlReaderContext!");
|
||||
@@ -72,7 +72,7 @@ public interface ConfigurationUtils {
|
||||
|
||||
Assert.notNull(resourceLoader, "ResourceLoader must not be null!");
|
||||
|
||||
var classLoader = resourceLoader.getClassLoader();
|
||||
ClassLoader classLoader = resourceLoader.getClassLoader();
|
||||
|
||||
if (classLoader == null) {
|
||||
throw new IllegalArgumentException("Could not obtain ClassLoader from ResourceLoader!");
|
||||
@@ -92,7 +92,7 @@ public interface ConfigurationUtils {
|
||||
|
||||
Assert.notNull(beanDefinition, "BeanDefinition must not be null!");
|
||||
|
||||
var result = beanDefinition.getBeanClassName();
|
||||
String result = beanDefinition.getBeanClassName();
|
||||
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class ParsingUtils {
|
||||
Assert.hasText(attrName, "Attribute name must not be null!");
|
||||
Assert.hasText(propertyName, "Property name must not be null!");
|
||||
|
||||
var attr = element.getAttribute(attrName);
|
||||
String attr = element.getAttribute(attrName);
|
||||
|
||||
if (StringUtils.hasText(attr)) {
|
||||
builder.addPropertyValue(propertyName, attr);
|
||||
@@ -90,7 +90,7 @@ public abstract class ParsingUtils {
|
||||
Assert.hasText(attribute, "Attribute name must not be null!");
|
||||
Assert.hasText(property, "Property name must not be null!");
|
||||
|
||||
var value = element.getAttribute(attribute);
|
||||
String value = element.getAttribute(attribute);
|
||||
|
||||
if (StringUtils.hasText(value)) {
|
||||
builder.addPropertyReference(property, value);
|
||||
@@ -126,7 +126,7 @@ public abstract class ParsingUtils {
|
||||
|
||||
Assert.notNull(builder, "Builder must not be null!");
|
||||
|
||||
var definition = builder.getRawBeanDefinition();
|
||||
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
|
||||
definition.setSource(source);
|
||||
return definition;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public abstract class ParsingUtils {
|
||||
|
||||
Assert.hasText(targetBeanName, "Target bean name must not be null or empty!");
|
||||
|
||||
var builder = BeanDefinitionBuilder.rootBeanDefinition(ObjectFactoryCreatingFactoryBean.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ObjectFactoryCreatingFactoryBean.class);
|
||||
builder.addPropertyValue("targetBeanName", targetBeanName);
|
||||
builder.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Parser to populate the given {@link ClassPathScanningCandidateComponentProvider} with {@link TypeFilter}s parsed from
|
||||
@@ -85,13 +86,13 @@ public class TypeFilterParser {
|
||||
*/
|
||||
public Collection<TypeFilter> parseTypeFilters(Element element, Type type) {
|
||||
|
||||
var nodeList = element.getChildNodes();
|
||||
NodeList nodeList = element.getChildNodes();
|
||||
Collection<TypeFilter> filters = new HashSet<>();
|
||||
|
||||
for (var i = 0; i < nodeList.getLength(); i++) {
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
|
||||
var node = nodeList.item(i);
|
||||
var childElement = type.getElement(node);
|
||||
Node node = nodeList.item(i);
|
||||
Element childElement = type.getElement(node);
|
||||
|
||||
if (childElement == null) {
|
||||
continue;
|
||||
@@ -116,12 +117,12 @@ public class TypeFilterParser {
|
||||
*/
|
||||
protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader) {
|
||||
|
||||
var filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
|
||||
var expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
|
||||
String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
|
||||
String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
|
||||
|
||||
try {
|
||||
|
||||
var filter = FilterType.fromString(filterType);
|
||||
FilterType filter = FilterType.fromString(filterType);
|
||||
return filter.getFilter(expression, classLoader);
|
||||
|
||||
} catch (ClassNotFoundException ex) {
|
||||
@@ -171,7 +172,7 @@ public class TypeFilterParser {
|
||||
@Override
|
||||
public TypeFilter getFilter(String expression, ClassLoader classLoader) throws ClassNotFoundException {
|
||||
|
||||
var filterClass = classLoader.loadClass(expression);
|
||||
Class<?> filterClass = classLoader.loadClass(expression);
|
||||
if (!TypeFilter.class.isAssignableFrom(filterClass)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression);
|
||||
@@ -199,7 +200,7 @@ public class TypeFilterParser {
|
||||
*/
|
||||
static FilterType fromString(String typeString) {
|
||||
|
||||
for (var filter : FilterType.values()) {
|
||||
for (FilterType filter : FilterType.values()) {
|
||||
if (filter.name().equalsIgnoreCase(typeString)) {
|
||||
return filter;
|
||||
}
|
||||
@@ -230,7 +231,7 @@ public class TypeFilterParser {
|
||||
Element getElement(Node node) {
|
||||
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
var localName = node.getLocalName();
|
||||
String localName = node.getLocalName();
|
||||
if (elementName.equals(localName)) {
|
||||
return (Element) node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user