Unify method visibility of private classes

Apply checkstyle rule to ensure that private and package private
classes do not have unnecessary public methods. Test classes have
also been unified as much as possible to use default scoped
inner-classes.

Closes gh-7316
This commit is contained in:
Phillip Webb
2019-07-01 12:29:51 -07:00
parent 0a02a3a19c
commit a66c4d3096
910 changed files with 3754 additions and 3945 deletions

View File

@@ -238,12 +238,12 @@ public class DevToolsIntegrationTests {
this.classesDirectory = classesDirectory;
}
public ControllerBuilder withRequestMapping(String mapping) {
ControllerBuilder withRequestMapping(String mapping) {
this.mappings.add(mapping);
return this;
}
public void build() throws Exception {
void build() throws Exception {
Builder<Object> builder = new ByteBuddy().subclass(Object.class).name(this.name)
.annotateType(AnnotationDescription.Builder.ofType(RestController.class).build());
for (String mapping : this.mappings) {

View File

@@ -137,12 +137,12 @@ public class DevToolsWithLazyInitializationIntegrationTests {
this.classesDirectory = classesDirectory;
}
public ControllerBuilder withRequestMapping(String mapping) {
ControllerBuilder withRequestMapping(String mapping) {
this.mappings.add(mapping);
return this;
}
public void build() throws Exception {
void build() throws Exception {
DynamicType.Builder<Object> builder = new ByteBuddy().subclass(Object.class).name(this.name)
.annotateType(AnnotationDescription.Builder.ofType(RestController.class).build());
for (String mapping : this.mappings) {

View File

@@ -48,7 +48,7 @@ class LaunchedApplication {
this.remoteProcessRestarter = remoteProcessRestarter;
}
public void restartRemote(int port) throws InterruptedException {
void restartRemote(int port) throws InterruptedException {
if (this.remoteProcessRestarter != null) {
stop(this.remoteProcess);
this.remoteProcess = this.remoteProcessRestarter.apply(port, this.classesDirectory);

View File

@@ -464,17 +464,16 @@ public class SysVinitLaunchScriptIT {
this.file = file;
}
public String getContainer() {
String getContainer() {
return this.container;
}
public File getFile() {
File getFile() {
return this.file;
}
@Override
public void close() {
}
}

View File

@@ -63,7 +63,7 @@ abstract class AbstractApplicationLauncher implements BeforeEachCallback, AfterE
this.process = startApplication();
}
public final int getHttpPort() {
final int getHttpPort() {
return this.httpPort;
}

View File

@@ -38,7 +38,7 @@ final class Versions {
private Versions() {
}
public static String getBootVersion() {
static String getBootVersion() {
String baseDir = StringUtils.cleanPath(new File(".").getAbsolutePath());
String mainBaseDir = evaluateExpression("pom.xml", PROPERTIES + "/*[local-name()='main.basedir']/text()");
mainBaseDir = mainBaseDir.replace("${basedir}", baseDir);

View File

@@ -85,19 +85,19 @@ class SampleAtmosphereApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public TextWebSocketHandler handler() {
TextWebSocketHandler handler() {
return new TextWebSocketHandler() {
@Override

View File

@@ -54,7 +54,7 @@ class SampleClient {
}
@Scheduled(fixedDelay = 500)
public void retrieveCountry() {
void retrieveCountry() {
String randomCode = SAMPLE_COUNTRY_CODES.get(this.random.nextInt(SAMPLE_COUNTRY_CODES.size()));
System.out.println("Looking for country with code '" + randomCode + "'");
this.countryService.findByCode(randomCode);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ import java.time.LocalDate;
import org.springframework.data.annotation.Id;
class Customer {
public class Customer {
@Id
private Long id;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
interface CustomerRepository extends CrudRepository<Customer, Long> {
public interface CustomerRepository extends CrudRepository<Customer, Long> {
@Query("select id, first_name, date_of_birth from customer where upper(first_name) like '%' || upper(:name) || '%' ")
List<Customer> findByName(@Param("name") String name);

View File

@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
class MessageController {
public class MessageController {
@GetMapping("/hi")
public String hello() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ class Consumer {
private final List<SampleMessage> messages = new CopyOnWriteArrayList<>();
@KafkaListener(topics = "testTopic")
public void processMessage(SampleMessage message) {
void processMessage(SampleMessage message) {
this.messages.add(message);
System.out.println("Received sample message [" + message + "]");
}

View File

@@ -91,7 +91,7 @@ class ManagementPortSampleSecureWebFluxTests {
static class SecurityConfiguration {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange().matchers(EndpointRequest.to("health", "info")).permitAll()
.matchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class)).hasRole("ACTUATOR")
.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll().pathMatchers("/login")

View File

@@ -105,7 +105,7 @@ class SampleSecureWebFluxCustomSecurityTests {
@SuppressWarnings("deprecation")
@Bean
public MapReactiveUserDetailsService userDetailsService() {
MapReactiveUserDetailsService userDetailsService() {
return new MapReactiveUserDetailsService(
User.withDefaultPasswordEncoder().username("user").password("password").authorities("ROLE_USER")
.build(),
@@ -114,7 +114,7 @@ class SampleSecureWebFluxCustomSecurityTests {
}
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange().matchers(EndpointRequest.to("health", "info")).permitAll()
.matchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class)).hasRole("ACTUATOR")
.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll().pathMatchers("/login")

View File

@@ -96,7 +96,7 @@ class MessageControllerWebTests {
description.appendText("a string that matches regex: ").appendText(this.regex);
}
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}

View File

@@ -96,7 +96,7 @@ class MessageControllerWebTests {
description.appendText("a string that matches regex: ").appendText(this.regex);
}
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}

View File

@@ -98,26 +98,24 @@ class SampleWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}

View File

@@ -113,26 +113,24 @@ class CustomContainerWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}

View File

@@ -98,26 +98,24 @@ class SampleWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}

View File

@@ -113,7 +113,7 @@ class CustomContainerWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
@@ -122,17 +122,17 @@ class CustomContainerWebSocketsApplicationTests {
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}

View File

@@ -98,26 +98,24 @@ class SampleWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
return manager;
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}

View File

@@ -113,7 +113,7 @@ class CustomContainerWebSocketsApplicationTests {
}
@Bean
public WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager wsConnectionManager() {
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
manager.setAutoStartup(true);
@@ -122,17 +122,17 @@ class CustomContainerWebSocketsApplicationTests {
}
@Bean
public StandardWebSocketClient client() {
StandardWebSocketClient client() {
return new StandardWebSocketClient();
}
@Bean
public SimpleClientWebSocketHandler handler() {
SimpleClientWebSocketHandler handler() {
return new SimpleClientWebSocketHandler(greetingService(), this.latch, this.messagePayload);
}
@Bean
public GreetingService greetingService() {
GreetingService greetingService() {
return new SimpleGreetingService();
}