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

@@ -89,7 +89,7 @@ public class Box implements Shape {
@Override
public int hashCode() {
var result = 31;
int result = 31;
result += 17 * first.hashCode();
result += 17 * second.hashCode();

View File

@@ -111,7 +111,7 @@ public class Circle implements Shape {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(center);
int result = ObjectUtils.nullSafeHashCode(center);
result = 31 * result + ObjectUtils.nullSafeHashCode(radius);
return result;
}

View File

@@ -121,7 +121,7 @@ public final class Distance implements Serializable, Comparable<Distance> {
Assert.notNull(other, "Distance to add must not be null!");
var newNormalizedValue = getNormalizedValue() + other.getNormalizedValue();
double newNormalizedValue = getNormalizedValue() + other.getNormalizedValue();
return new Distance(newNormalizedValue * metric.getMultiplier(), metric);
}
@@ -138,8 +138,8 @@ public final class Distance implements Serializable, Comparable<Distance> {
Assert.notNull(other, "Distance to must not be null!");
Assert.notNull(metric, "Result metric must not be null!");
var newLeft = getNormalizedValue() * metric.getMultiplier();
var newRight = other.getNormalizedValue() * metric.getMultiplier();
double newLeft = getNormalizedValue() * metric.getMultiplier();
double newRight = other.getNormalizedValue() * metric.getMultiplier();
return new Distance(newLeft + newRight, metric);
}
@@ -165,7 +165,7 @@ public final class Distance implements Serializable, Comparable<Distance> {
return 1;
}
var difference = this.getNormalizedValue() - that.getNormalizedValue();
double difference = this.getNormalizedValue() - that.getNormalizedValue();
return difference == 0 ? 0 : difference > 0 ? 1 : -1;
}
@@ -173,7 +173,7 @@ public final class Distance implements Serializable, Comparable<Distance> {
@Override
public String toString() {
var builder = new StringBuilder();
StringBuilder builder = new StringBuilder();
builder.append(value);
if (metric != Metrics.NEUTRAL) {

View File

@@ -71,7 +71,7 @@ public final class GeoResult<T> implements Serializable {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(content);
int result = ObjectUtils.nullSafeHashCode(content);
result = 31 * result + ObjectUtils.nullSafeHashCode(distance);
return result;
}

View File

@@ -120,7 +120,7 @@ public class GeoResults<T> implements Iterable<GeoResult<T>>, Serializable {
@Override
public int hashCode() {
var result = ObjectUtils.nullSafeHashCode(results);
int result = ObjectUtils.nullSafeHashCode(results);
result = 31 * result + ObjectUtils.nullSafeHashCode(averageDistance);
return result;
}
@@ -140,7 +140,7 @@ public class GeoResults<T> implements Iterable<GeoResult<T>>, Serializable {
return new Distance(0, metric);
}
var averageDistance = results.stream()//
double averageDistance = results.stream()//
.mapToDouble(it -> it.getDistance().getValue())//
.average().orElse(0);

View File

@@ -83,9 +83,9 @@ public class Point implements Serializable {
@Override
public int hashCode() {
var result = 1;
int result = 1;
var temp = Double.doubleToLongBits(x);
long temp = Double.doubleToLongBits(x);
result = 31 * result + (int) (temp ^ temp >>> 32);
temp = Double.doubleToLongBits(y);

View File

@@ -82,7 +82,7 @@ public enum DistanceFormatter implements Converter<String, Distance>, Formatter<
*/
private static Distance doConvert(String source) {
for (var metric : SUPPORTED_METRICS.entrySet()) {
for (Entry<String, Metric> metric : SUPPORTED_METRICS.entrySet()) {
if (source.endsWith(metric.getKey())) {
return fromString(source, metric);
}
@@ -105,7 +105,7 @@ public enum DistanceFormatter implements Converter<String, Distance>, Formatter<
*/
private static Distance fromString(String source, Entry<String, Metric> metric) {
var amountString = source.substring(0, source.indexOf(metric.getKey()));
String amountString = source.substring(0, source.indexOf(metric.getKey()));
try {
return new Distance(Double.parseDouble(amountString), metric.getValue());

View File

@@ -41,7 +41,7 @@ public enum PointFormatter implements Converter<String, Point>, Formatter<Point>
@Override
public Point convert(String source) {
var parts = source.split(",");
String[] parts = source.split(",");
if (parts.length != 2) {
throw new IllegalArgumentException(String.format(INVALID_FORMAT, source));
@@ -49,8 +49,8 @@ public enum PointFormatter implements Converter<String, Point>, Formatter<Point>
try {
var latitude = Double.parseDouble(parts[0]);
var longitude = Double.parseDouble(parts[1]);
double latitude = Double.parseDouble(parts[0]);
double longitude = Double.parseDouble(parts[1]);
return new Point(longitude, latitude);