From 9ca9a491ca79d1018436466ea5ee9cb93dc7bb32 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sat, 28 Jul 2018 10:41:56 +0100 Subject: [PATCH] Fix checkstyle issues in samples Fix checkstyle issues with samples following the spring-javaformat upgrade. See gh-13932 --- .../main/java/sample/data/jpa/domain/HotelSummary.java | 2 +- .../java/sample/data/jpa/service/HotelServiceImpl.java | 2 +- .../test/domain/VehicleIdentificationNumber.java | 10 +++++----- .../main/java/sample/test/service/VehicleDetails.java | 10 +++++----- .../websocket/jetty/echo/DefaultEchoService.java | 2 +- .../websocket/tomcat/echo/DefaultEchoService.java | 2 +- .../websocket/undertow/echo/DefaultEchoService.java | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java index 35b4b3e262..c22e8ad760 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java @@ -25,7 +25,7 @@ public interface HotelSummary { Double getAverageRating(); default Integer getAverageRatingRounded() { - return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null); + return (getAverageRating() != null) ? (int) Math.round(getAverageRating()) : null; } } diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java index 0969ca601e..427f659cb8 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java @@ -91,7 +91,7 @@ class HotelServiceImpl implements HotelService { @Override public long getNumberOfReviewsWithRating(Rating rating) { Long count = this.ratingCount.get(rating); - return (count != null ? count : 0); + return (count != null) ? count : 0; } } diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java index c3ac249fe8..003b490237 100644 --- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java +++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java @@ -33,11 +33,6 @@ public final class VehicleIdentificationNumber { this.vin = vin; } - @Override - public int hashCode() { - return this.vin.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -49,6 +44,11 @@ public final class VehicleIdentificationNumber { return this.vin.equals(((VehicleIdentificationNumber) obj).vin); } + @Override + public int hashCode() { + return this.vin.hashCode(); + } + @Override public String toString() { return this.vin; diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java index e0515ff56d..b565fc0f99 100644 --- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java +++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java @@ -49,11 +49,6 @@ public class VehicleDetails { return this.model; } - @Override - public int hashCode() { - return this.make.hashCode() * 31 + this.model.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -66,4 +61,9 @@ public class VehicleDetails { return this.make.equals(other.make) && this.model.equals(other.model); } + @Override + public int hashCode() { + return this.make.hashCode() * 31 + this.model.hashCode(); + } + } diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java index dcb00af08e..91a128c3a5 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java index d6b82ce10a..d20efe0479 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java index 0326a0a2d7..aa5c28ee6d 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override