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:
Mark Paluch
2022-03-28 08:55:29 +02:00
parent c85c4ef2ed
commit 0e5e869cbf
249 changed files with 1662 additions and 1507 deletions

View File

@@ -86,8 +86,8 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
@Override
public int hashCode() {
final var prime = 31;
var result = 1;
final int prime = 31;
int result = 1;
result = prime * result + page;
result = prime * result + size;
@@ -106,7 +106,7 @@ public abstract class AbstractPageRequest implements Pageable, Serializable {
return false;
}
var other = (AbstractPageRequest) obj;
AbstractPageRequest other = (AbstractPageRequest) obj;
return this.page == other.page && this.size == other.size;
}
}

View File

@@ -132,8 +132,8 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
return false;
}
var contentEqual = this.content.equals(that.content);
var pageableEqual = this.pageable.equals(that.pageable);
boolean contentEqual = this.content.equals(that.content);
boolean pageableEqual = this.pageable.equals(that.pageable);
return contentEqual && pageableEqual;
}
@@ -141,7 +141,7 @@ abstract class Chunk<T> implements Slice<T>, Serializable {
@Override
public int hashCode() {
var result = 17;
int result = 17;
result += 31 * pageable.hashCode();
result += 31 * content.hashCode();

View File

@@ -124,7 +124,7 @@ public interface ExampleMatcher {
Assert.hasText(propertyPath, "PropertyPath must not be empty!");
Assert.notNull(matcherConfigurer, "MatcherConfigurer must not be empty!");
var genericPropertyMatcher = new GenericPropertyMatcher();
GenericPropertyMatcher genericPropertyMatcher = new GenericPropertyMatcher();
matcherConfigurer.configureMatcher(genericPropertyMatcher);
return withMatcher(propertyPath, genericPropertyMatcher);
@@ -463,7 +463,7 @@ public interface ExampleMatcher {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(stringMatcher);
int result = ObjectUtils.nullSafeHashCode(stringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase);
result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer);
return result;
@@ -753,7 +753,7 @@ public interface ExampleMatcher {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(path);
int result = ObjectUtils.nullSafeHashCode(path);
result = 31 * result + ObjectUtils.nullSafeHashCode(stringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoreCase);
result = 31 * result + ObjectUtils.nullSafeHashCode(valueTransformer);

View File

@@ -89,8 +89,8 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
@Override
public String toString() {
var contentType = "UNKNOWN";
var content = getContent();
String contentType = "UNKNOWN";
List<T> content = getContent();
if (!content.isEmpty() && content.get(0) != null) {
contentType = content.get(0).getClass().getName();
@@ -116,7 +116,7 @@ public class PageImpl<T> extends Chunk<T> implements Page<T> {
@Override
public int hashCode() {
var result = 17;
int result = 17;
result += 31 * (int) (total ^ total >>> 32);
result += 31 * super.hashCode();

View File

@@ -231,7 +231,7 @@ public final class Range<T extends Comparable<T>> {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(lowerBound);
int result = ObjectUtils.nullSafeHashCode(lowerBound);
result = 31 * result + ObjectUtils.nullSafeHashCode(upperBound);
return result;
}
@@ -426,7 +426,7 @@ public final class Range<T extends Comparable<T>> {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(value);
int result = ObjectUtils.nullSafeHashCode(value);
result = 31 * result + (inclusive ? 1 : 0);
return result;
}

View File

@@ -71,8 +71,8 @@ public class SliceImpl<T> extends Chunk<T> {
@Override
public String toString() {
var contentType = "UNKNOWN";
var content = getContent();
String contentType = "UNKNOWN";
List<T> content = getContent();
if (content.size() > 0) {
contentType = content.get(0).getClass().getName();
@@ -98,7 +98,7 @@ public class SliceImpl<T> extends Chunk<T> {
@Override
public int hashCode() {
var result = 17;
int result = 17;
result += 31 * (hasNext ? 1 : 0);
result += 31 * super.hashCode();

View File

@@ -193,9 +193,9 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
Assert.notNull(sort, "Sort must not be null!");
var these = new ArrayList<Order>(this.toList());
ArrayList<Order> these = new ArrayList<Order>(this.toList());
for (var order : sort) {
for (Order order : sort) {
these.add(order);
}
@@ -211,7 +211,7 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
@Nullable
public Order getOrderFor(String property) {
for (var order : this) {
for (Order order : this) {
if (order.getProperty().equals(property)) {
return order;
}
@@ -241,7 +241,7 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
@Override
public int hashCode() {
var result = 17;
int result = 17;
result = 31 * result + orders.hashCode();
return result;
}
@@ -585,7 +585,7 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
@Override
public int hashCode() {
var result = 17;
int result = 17;
result = 31 * result + direction.hashCode();
result = 31 * result + property.hashCode();
@@ -613,7 +613,7 @@ public class Sort implements Streamable<org.springframework.data.domain.Sort.Ord
@Override
public String toString() {
var result = String.format("%s: %s", property, direction);
String result = String.format("%s: %s", property, direction);
if (!NullHandling.NATIVE.equals(nullHandling)) {
result += ", " + nullHandling;

View File

@@ -66,7 +66,7 @@ class TypedExample<T> implements Example<T> {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(probe);
int result = ObjectUtils.nullSafeHashCode(probe);
result = 31 * result + ObjectUtils.nullSafeHashCode(matcher);
return result;
}

View File

@@ -89,8 +89,8 @@ class TypedExampleMatcher implements ExampleMatcher {
Assert.hasText(propertyPath, "PropertyPath must not be empty!");
Assert.notNull(genericPropertyMatcher, "GenericPropertyMatcher must not be empty!");
var propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
var propertySpecifier = new PropertySpecifier(propertyPath);
PropertySpecifiers propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
PropertySpecifier propertySpecifier = new PropertySpecifier(propertyPath);
if (genericPropertyMatcher.ignoreCase != null) {
propertySpecifier = propertySpecifier.withIgnoreCase(genericPropertyMatcher.ignoreCase);
@@ -114,8 +114,8 @@ class TypedExampleMatcher implements ExampleMatcher {
Assert.hasText(propertyPath, "PropertyPath must not be empty!");
Assert.notNull(propertyValueTransformer, "PropertyValueTransformer must not be empty!");
var propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
var propertySpecifier = getOrCreatePropertySpecifier(propertyPath, propertySpecifiers);
PropertySpecifiers propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
PropertySpecifier propertySpecifier = getOrCreatePropertySpecifier(propertyPath, propertySpecifiers);
propertySpecifiers.add(propertySpecifier.withValueTransformer(propertyValueTransformer));
@@ -129,10 +129,10 @@ class TypedExampleMatcher implements ExampleMatcher {
Assert.notEmpty(propertyPaths, "PropertyPaths must not be empty!");
Assert.noNullElements(propertyPaths, "PropertyPaths must not contain null elements!");
var propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
PropertySpecifiers propertySpecifiers = new PropertySpecifiers(this.propertySpecifiers);
for (var propertyPath : propertyPaths) {
var propertySpecifier = getOrCreatePropertySpecifier(propertyPath, propertySpecifiers);
for (String propertyPath : propertyPaths) {
PropertySpecifier propertySpecifier = getOrCreatePropertySpecifier(propertyPath, propertySpecifiers);
propertySpecifiers.add(propertySpecifier.withIgnoreCase(true));
}
@@ -230,7 +230,7 @@ class TypedExampleMatcher implements ExampleMatcher {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(nullHandler);
int result = ObjectUtils.nullSafeHashCode(nullHandler);
result = 31 * result + ObjectUtils.nullSafeHashCode(defaultStringMatcher);
result = 31 * result + ObjectUtils.nullSafeHashCode(propertySpecifiers);
result = 31 * result + ObjectUtils.nullSafeHashCode(ignoredPaths);

View File

@@ -17,6 +17,7 @@ package org.springframework.data.domain.jaxb;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.domain.jaxb.SpringDataJaxb.OrderDto;
import org.springframework.lang.Nullable;
@@ -38,7 +39,7 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
return null;
}
var dto = new OrderDto();
OrderDto dto = new OrderDto();
dto.direction = order.getDirection();
dto.property = order.getProperty();
return dto;
@@ -52,8 +53,8 @@ public class OrderAdapter extends XmlAdapter<OrderDto, Order> {
return null;
}
var direction = source.direction;
var property = source.property;
Sort.Direction direction = source.direction;
String property = source.property;
if (direction == null || property == null) {
return null;

View File

@@ -40,7 +40,7 @@ public class PageAdapter extends XmlAdapter<PageDto, Page<Object>> {
return null;
}
var dto = new PageDto();
PageDto dto = new PageDto();
dto.content = source.getContent();
dto.add(getLinks(source));

View File

@@ -42,9 +42,9 @@ class PageableAdapter extends XmlAdapter<PageRequestDto, Pageable> {
return null;
}
var dto = new PageRequestDto();
PageRequestDto dto = new PageRequestDto();
var sortDto = SortAdapter.INSTANCE.marshal(request.getSort());
SortDto sortDto = SortAdapter.INSTANCE.marshal(request.getSort());
dto.orders = sortDto == null ? Collections.emptyList() : sortDto.orders;
dto.page = request.getPageNumber();
dto.size = request.getPageSize();
@@ -64,7 +64,7 @@ class PageableAdapter extends XmlAdapter<PageRequestDto, Pageable> {
return PageRequest.of(v.page, v.size);
}
var sortDto = new SortDto();
SortDto sortDto = new SortDto();
sortDto.orders = v.orders;
return PageRequest.of(v.page, v.size, SortAdapter.INSTANCE.unmarshal(sortDto));

View File

@@ -39,7 +39,7 @@ public class SortAdapter extends XmlAdapter<SortDto, Sort> {
return null;
}
var dto = new SortDto();
SortDto dto = new SortDto();
dto.orders = SpringDataJaxb.marshal(source, OrderAdapter.INSTANCE);
return dto;

View File

@@ -119,7 +119,7 @@ public abstract class SpringDataJaxb {
List<T> result = new ArrayList<>(source.size());
for (var element : source) {
for (S element : source) {
try {
result.add(adapter.unmarshal(element));
} catch (Exception o_O) {
@@ -146,7 +146,7 @@ public abstract class SpringDataJaxb {
List<S> result = new ArrayList<>();
for (var element : source) {
for (T element : source) {
try {
result.add(adapter.marshal(element));
} catch (Exception o_O) {