Skip to content

Commit 0e5e869

Browse files
committed
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
1 parent c85c4ef commit 0e5e869

File tree

249 files changed

+1662
-1507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+1662
-1507
lines changed

src/main/java/org/springframework/data/auditing/AnnotationAuditingMetadata.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void assertValidDateFieldType(Optional<Field> field) {
101101
return;
102102
}
103103

104-
var type = it.getType();
104+
Class<?> type = it.getType();
105105

106106
if (Jsr310Converters.supports(type)) {
107107
return;

src/main/java/org/springframework/data/auditing/AuditingHandlerSupport.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <T> T markModified(Auditor<?> auditor, T source) {
129129

130130
private <T> T touch(Auditor<?> auditor, T target, boolean isNew) {
131131

132-
var wrapper = factory.getBeanWrapperFor(target);
132+
Optional<AuditableBeanWrapper<T>> wrapper = factory.getBeanWrapperFor(target);
133133

134134
return wrapper.map(it -> {
135135

@@ -185,7 +185,7 @@ private Optional<TemporalAccessor> touchDate(AuditableBeanWrapper<?> wrapper, bo
185185

186186
Assert.notNull(wrapper, "AuditableBeanWrapper must not be null!");
187187

188-
var now = dateTimeProvider.getNow();
188+
Optional<TemporalAccessor> now = dateTimeProvider.getNow();
189189

190190
Assert.notNull(now, () -> String.format("Now must not be null! Returned by: %s!", dateTimeProvider.getClass()));
191191

src/main/java/org/springframework/data/auditing/Auditor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public boolean equals(Object o) {
110110
if (o == null || getClass() != o.getClass())
111111
return false;
112112

113-
var auditor = (Auditor<?>) o;
113+
Auditor<?> auditor = (Auditor<?>) o;
114114

115115
return ObjectUtils.nullSafeEquals(value, auditor.value);
116116
}

src/main/java/org/springframework/data/auditing/DefaultAuditableBeanWrapperFactory.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DefaultAuditableBeanWrapperFactory implements AuditableBeanWrapperFactory
4646

4747
public DefaultAuditableBeanWrapperFactory() {
4848

49-
var conversionService = new DefaultFormattingConversionService();
49+
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
5050

5151
Jsr310Converters.getConvertersToRegister().forEach(conversionService::addConverter);
5252

@@ -75,7 +75,7 @@ public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) {
7575
return (AuditableBeanWrapper<T>) new AuditableInterfaceBeanWrapper(conversionService, (Auditable<Object, ?, TemporalAccessor>) it);
7676
}
7777

78-
var metadata = AnnotationAuditingMetadata.getMetadata(it.getClass());
78+
AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata.getMetadata(it.getClass());
7979

8080
if (metadata.isAuditable()) {
8181
return new ReflectionAuditingBeanWrapper<T>(conversionService, it);
@@ -191,7 +191,7 @@ protected Object getDateValueToSet(TemporalAccessor value, Class<?> targetType,
191191
value.getClass(), targetType));
192192
}
193193

194-
var date = conversionService.convert(value, Date.class);
194+
Date date = conversionService.convert(value, Date.class);
195195
return conversionService.convert(date, targetType);
196196
}
197197

@@ -277,7 +277,7 @@ public Optional<TemporalAccessor> getLastModifiedDate() {
277277

278278
return getAsTemporalAccessor(metadata.getLastModifiedDateField().map(field -> {
279279

280-
var value = org.springframework.util.ReflectionUtils.getField(field, target);
280+
Object value = org.springframework.util.ReflectionUtils.getField(field, target);
281281
return value instanceof Optional ? ((Optional<?>) value).orElse(null) : value;
282282

283283
}), TemporalAccessor.class);

src/main/java/org/springframework/data/auditing/IsNewAwareAuditingHandler.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.auditing;
1717

1818
import org.springframework.data.mapping.PersistentEntity;
19+
import org.springframework.data.mapping.PersistentProperty;
1920
import org.springframework.data.mapping.context.MappingContext;
2021
import org.springframework.data.mapping.context.PersistentEntities;
2122
import org.springframework.data.support.IsNewStrategy;
@@ -61,7 +62,7 @@ public Object markAudited(Object object) {
6162
return object;
6263
}
6364

64-
var entity = entities
65+
PersistentEntity<?, ? extends PersistentProperty<?>> entity = entities
6566
.getRequiredPersistentEntity(object.getClass());
6667

6768
return entity.isNew(object) ? markCreated(object) : markModified(object);

src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) {
8181

8282
return entities.mapOnContext(it.getClass(), (context, entity) -> {
8383

84-
var metadata = metadataCache.computeIfAbsent(it.getClass(),
84+
MappingAuditingMetadata metadata = metadataCache.computeIfAbsent(it.getClass(),
8585
key -> new MappingAuditingMetadata(context, it.getClass()));
8686

8787
return Optional.<AuditableBeanWrapper<T>> ofNullable(metadata.isAuditable() //
@@ -209,7 +209,7 @@ public Object setLastModifiedBy(Object value) {
209209
@Override
210210
public Optional<TemporalAccessor> getLastModifiedDate() {
211211

212-
var firstValue = metadata.lastModifiedDatePaths.getFirst() //
212+
Optional<Object> firstValue = metadata.lastModifiedDatePaths.getFirst() //
213213
.map(accessor::getProperty);
214214

215215
return getAsTemporalAccessor(firstValue, TemporalAccessor.class);
@@ -238,7 +238,7 @@ private TemporalAccessor setDateProperty(
238238

239239
property.forEach(it -> {
240240

241-
var type = it.getRequiredLeafProperty().getType();
241+
Class<?> type = it.getRequiredLeafProperty().getType();
242242

243243
this.accessor.setProperty(it, getDateValueToSet(value, type, accessor.getBean()), OPTIONS);
244244
});

src/main/java/org/springframework/data/auditing/ReactiveIsNewAwareAuditingHandler.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import reactor.core.publisher.Mono;
1919

2020
import org.springframework.data.mapping.PersistentEntity;
21+
import org.springframework.data.mapping.PersistentProperty;
2122
import org.springframework.data.mapping.context.MappingContext;
2223
import org.springframework.data.mapping.context.PersistentEntities;
2324
import org.springframework.data.support.IsNewStrategy;
@@ -61,7 +62,7 @@ public Mono<Object> markAudited(Object object) {
6162
return Mono.just(object);
6263
}
6364

64-
var entity = entities
65+
PersistentEntity<?, ? extends PersistentProperty<?>> entity = entities
6566
.getRequiredPersistentEntity(object.getClass());
6667

6768
return entity.isNew(object) ? markCreated(object) : markModified(object);

src/main/java/org/springframework/data/auditing/config/AnnotationAuditingConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.auditing.config;
1717

1818
import java.lang.annotation.Annotation;
19+
import java.util.Map;
1920

2021
import org.springframework.core.annotation.AnnotationAttributes;
2122
import org.springframework.core.type.AnnotationMetadata;
@@ -46,7 +47,7 @@ public AnnotationAuditingConfiguration(AnnotationMetadata metadata, Class<? exte
4647
Assert.notNull(metadata, "AnnotationMetadata must not be null!");
4748
Assert.notNull(annotation, "Annotation must not be null!");
4849

49-
var attributesSource = metadata.getAnnotationAttributes(annotation.getName());
50+
Map<String, Object> attributesSource = metadata.getAnnotationAttributes(annotation.getName());
5051

5152
if (attributesSource == null) {
5253
throw new IllegalArgumentException(String.format(MISSING_ANNOTATION_ATTRIBUTES, annotation, metadata));

src/main/java/org/springframework/data/auditing/config/AuditingBeanDefinitionRegistrarSupport.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanD
5656
Assert.notNull(annotationMetadata, "AnnotationMetadata must not be null!");
5757
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");
5858

59-
var ahbd = registerAuditHandlerBeanDefinition(registry, getConfiguration(annotationMetadata));
59+
AbstractBeanDefinition ahbd = registerAuditHandlerBeanDefinition(registry, getConfiguration(annotationMetadata));
6060
registerAuditListenerBeanDefinition(ahbd, registry);
6161
}
6262

@@ -73,7 +73,7 @@ private AbstractBeanDefinition registerAuditHandlerBeanDefinition(BeanDefinition
7373
Assert.notNull(registry, "BeanDefinitionRegistry must not be null!");
7474
Assert.notNull(configuration, "AuditingConfiguration must not be null!");
7575

76-
var ahbd = getAuditHandlerBeanDefinitionBuilder(configuration).getBeanDefinition();
76+
AbstractBeanDefinition ahbd = getAuditHandlerBeanDefinitionBuilder(configuration).getBeanDefinition();
7777
registry.registerBeanDefinition(getAuditingHandlerBeanName(), ahbd);
7878
return ahbd;
7979
}
@@ -174,10 +174,10 @@ protected void registerInfrastructureBeanWithId(AbstractBeanDefinition definitio
174174

175175
private BeanDefinition createLazyInitTargetSourceBeanDefinition(String auditorAwareRef) {
176176

177-
var targetSourceBuilder = rootBeanDefinition(LazyInitTargetSource.class);
177+
BeanDefinitionBuilder targetSourceBuilder = rootBeanDefinition(LazyInitTargetSource.class);
178178
targetSourceBuilder.addPropertyValue("targetBeanName", auditorAwareRef);
179179

180-
var builder = rootBeanDefinition(ProxyFactoryBean.class);
180+
BeanDefinitionBuilder builder = rootBeanDefinition(ProxyFactoryBean.class);
181181
builder.addPropertyValue("targetSource", targetSourceBuilder.getBeanDefinition());
182182

183183
return builder.getBeanDefinition();

src/main/java/org/springframework/data/auditing/config/AuditingHandlerBeanDefinitionParser.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ protected boolean shouldGenerateId() {
8383
@Override
8484
protected void doParse(Element element, BeanDefinitionBuilder builder) {
8585

86-
final var persistentEntities = rootBeanDefinition(PersistentEntitiesFactoryBean.class);
86+
final BeanDefinitionBuilder persistentEntities = rootBeanDefinition(PersistentEntitiesFactoryBean.class);
8787
persistentEntities.addConstructorArgReference(mappingContextBeanName);
8888
builder.addConstructorArgValue(persistentEntities.getBeanDefinition());
8989

90-
var auditorAwareRef = element.getAttribute(AUDITOR_AWARE_REF);
90+
String auditorAwareRef = element.getAttribute(AUDITOR_AWARE_REF);
9191

9292
if (StringUtils.hasText(auditorAwareRef)) {
9393
builder.addPropertyValue("auditorAware", createLazyInitTargetSourceBeanDefinition(auditorAwareRef));
@@ -107,10 +107,10 @@ protected String resolveId(Element element, AbstractBeanDefinition definition, P
107107

108108
private BeanDefinition createLazyInitTargetSourceBeanDefinition(String auditorAwareRef) {
109109

110-
var targetSourceBuilder = rootBeanDefinition(LazyInitTargetSource.class);
110+
BeanDefinitionBuilder targetSourceBuilder = rootBeanDefinition(LazyInitTargetSource.class);
111111
targetSourceBuilder.addPropertyValue("targetBeanName", auditorAwareRef);
112112

113-
var builder = rootBeanDefinition(ProxyFactoryBean.class);
113+
BeanDefinitionBuilder builder = rootBeanDefinition(ProxyFactoryBean.class);
114114
builder.addPropertyValue("targetSource", targetSourceBuilder.getBeanDefinition());
115115

116116
return builder.getBeanDefinition();

src/main/java/org/springframework/data/config/BeanComponentDefinitionBuilder.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.config;
1717

1818
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
19+
import org.springframework.beans.factory.support.AbstractBeanDefinition;
1920
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
2021
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
2122
import org.springframework.beans.factory.xml.ParserContext;
@@ -60,8 +61,8 @@ public BeanComponentDefinition getComponent(BeanDefinitionBuilder builder) {
6061

6162
Assert.notNull(builder, "Builder must not be null!");
6263

63-
var definition = builder.getRawBeanDefinition();
64-
var name = BeanDefinitionReaderUtils.generateBeanName(definition, context.getRegistry(), context.isNested());
64+
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
65+
String name = BeanDefinitionReaderUtils.generateBeanName(definition, context.getRegistry(), context.isNested());
6566

6667
return getComponent(builder, name);
6768
}
@@ -78,7 +79,7 @@ public BeanComponentDefinition getComponentIdButFallback(BeanDefinitionBuilder b
7879

7980
Assert.hasText(fallback, "Fallback component id must not be null or empty!");
8081

81-
var id = defaultSource.getAttribute("id");
82+
String id = defaultSource.getAttribute("id");
8283
return getComponent(builder, StringUtils.hasText(id) ? id : fallback);
8384
}
8485

@@ -107,7 +108,7 @@ public BeanComponentDefinition getComponent(BeanDefinitionBuilder builder, Strin
107108
Assert.notNull(builder, "Builder must not be null!");
108109
Assert.hasText(name, "Name of bean must not be null or empty!");
109110

110-
var definition = builder.getRawBeanDefinition();
111+
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
111112
definition.setSource(context.extractSource(rawSource));
112113

113114
return new BeanComponentDefinition(definition, name);

src/main/java/org/springframework/data/config/ConfigurationUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static ResourceLoader getRequiredResourceLoader(XmlReaderContext context)
4141

4242
Assert.notNull(context, "XmlReaderContext must not be null!");
4343

44-
var resourceLoader = context.getResourceLoader();
44+
ResourceLoader resourceLoader = context.getResourceLoader();
4545

4646
if (resourceLoader == null) {
4747
throw new IllegalArgumentException("Could not obtain ResourceLoader from XmlReaderContext!");
@@ -72,7 +72,7 @@ public static ClassLoader getRequiredClassLoader(ResourceLoader resourceLoader)
7272

7373
Assert.notNull(resourceLoader, "ResourceLoader must not be null!");
7474

75-
var classLoader = resourceLoader.getClassLoader();
75+
ClassLoader classLoader = resourceLoader.getClassLoader();
7676

7777
if (classLoader == null) {
7878
throw new IllegalArgumentException("Could not obtain ClassLoader from ResourceLoader!");
@@ -92,7 +92,7 @@ public static String getRequiredBeanClassName(BeanDefinition beanDefinition) {
9292

9393
Assert.notNull(beanDefinition, "BeanDefinition must not be null!");
9494

95-
var result = beanDefinition.getBeanClassName();
95+
String result = beanDefinition.getBeanClassName();
9696

9797
if (result == null) {
9898
throw new IllegalArgumentException(

src/main/java/org/springframework/data/config/ParsingUtils.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void setPropertyValue(BeanDefinitionBuilder builder, Element eleme
5555
Assert.hasText(attrName, "Attribute name must not be null!");
5656
Assert.hasText(propertyName, "Property name must not be null!");
5757

58-
var attr = element.getAttribute(attrName);
58+
String attr = element.getAttribute(attrName);
5959

6060
if (StringUtils.hasText(attr)) {
6161
builder.addPropertyValue(propertyName, attr);
@@ -90,7 +90,7 @@ public static void setPropertyReference(BeanDefinitionBuilder builder, Element e
9090
Assert.hasText(attribute, "Attribute name must not be null!");
9191
Assert.hasText(property, "Property name must not be null!");
9292

93-
var value = element.getAttribute(attribute);
93+
String value = element.getAttribute(attribute);
9494

9595
if (StringUtils.hasText(value)) {
9696
builder.addPropertyReference(property, value);
@@ -126,7 +126,7 @@ public static AbstractBeanDefinition getSourceBeanDefinition(BeanDefinitionBuild
126126

127127
Assert.notNull(builder, "Builder must not be null!");
128128

129-
var definition = builder.getRawBeanDefinition();
129+
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
130130
definition.setSource(source);
131131
return definition;
132132
}
@@ -143,7 +143,7 @@ public static AbstractBeanDefinition getObjectFactoryBeanDefinition(String targe
143143

144144
Assert.hasText(targetBeanName, "Target bean name must not be null or empty!");
145145

146-
var builder = BeanDefinitionBuilder.rootBeanDefinition(ObjectFactoryCreatingFactoryBean.class);
146+
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ObjectFactoryCreatingFactoryBean.class);
147147
builder.addPropertyValue("targetBeanName", targetBeanName);
148148
builder.setRole(AbstractBeanDefinition.ROLE_INFRASTRUCTURE);
149149

src/main/java/org/springframework/data/config/TypeFilterParser.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import org.w3c.dom.Element;
3737
import org.w3c.dom.Node;
38+
import org.w3c.dom.NodeList;
3839

3940
/**
4041
* Parser to populate the given {@link ClassPathScanningCandidateComponentProvider} with {@link TypeFilter}s parsed from
@@ -85,13 +86,13 @@ public TypeFilterParser(XmlReaderContext readerContext) {
8586
*/
8687
public Collection<TypeFilter> parseTypeFilters(Element element, Type type) {
8788

88-
var nodeList = element.getChildNodes();
89+
NodeList nodeList = element.getChildNodes();
8990
Collection<TypeFilter> filters = new HashSet<>();
9091

91-
for (var i = 0; i < nodeList.getLength(); i++) {
92+
for (int i = 0; i < nodeList.getLength(); i++) {
9293

93-
var node = nodeList.item(i);
94-
var childElement = type.getElement(node);
94+
Node node = nodeList.item(i);
95+
Element childElement = type.getElement(node);
9596

9697
if (childElement == null) {
9798
continue;
@@ -116,12 +117,12 @@ public Collection<TypeFilter> parseTypeFilters(Element element, Type type) {
116117
*/
117118
protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader) {
118119

119-
var filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
120-
var expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
120+
String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
121+
String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
121122

122123
try {
123124

124-
var filter = FilterType.fromString(filterType);
125+
FilterType filter = FilterType.fromString(filterType);
125126
return filter.getFilter(expression, classLoader);
126127

127128
} catch (ClassNotFoundException ex) {
@@ -171,7 +172,7 @@ public TypeFilter getFilter(String expression, ClassLoader classLoader) {
171172
@Override
172173
public TypeFilter getFilter(String expression, ClassLoader classLoader) throws ClassNotFoundException {
173174

174-
var filterClass = classLoader.loadClass(expression);
175+
Class<?> filterClass = classLoader.loadClass(expression);
175176
if (!TypeFilter.class.isAssignableFrom(filterClass)) {
176177
throw new IllegalArgumentException(
177178
"Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression);
@@ -199,7 +200,7 @@ public TypeFilter getFilter(String expression, ClassLoader classLoader) throws C
199200
*/
200201
static FilterType fromString(String typeString) {
201202

202-
for (var filter : FilterType.values()) {
203+
for (FilterType filter : FilterType.values()) {
203204
if (filter.name().equalsIgnoreCase(typeString)) {
204205
return filter;
205206
}
@@ -230,7 +231,7 @@ public enum Type {
230231
Element getElement(Node node) {
231232

232233
if (node.getNodeType() == Node.ELEMENT_NODE) {
233-
var localName = node.getLocalName();
234+
String localName = node.getLocalName();
234235
if (elementName.equals(localName)) {
235236
return (Element) node;
236237
}

src/main/java/org/springframework/data/convert/ConfigurableTypeInformationMapper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public ConfigurableTypeInformationMapper(Map<? extends Class<?>, String> sourceT
5353

5454
for (Entry<? extends Class<?>, String> entry : sourceTypeMap.entrySet()) {
5555

56-
var type = ClassTypeInformation.from(entry.getKey());
57-
var alias = Alias.of(entry.getValue());
56+
ClassTypeInformation<?> type = ClassTypeInformation.from(entry.getKey());
57+
Alias alias = Alias.of(entry.getValue());
5858

5959
if (typeToAlias.containsValue(alias)) {
6060
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)