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:
@@ -68,18 +68,18 @@ public class LocalDevToolsAutoConfiguration {
|
||||
@Bean
|
||||
@RestartScope
|
||||
@ConditionalOnMissingBean
|
||||
public LiveReloadServer liveReloadServer(DevToolsProperties properties) {
|
||||
LiveReloadServer liveReloadServer(DevToolsProperties properties) {
|
||||
return new LiveReloadServer(properties.getLivereload().getPort(),
|
||||
Restarter.getInstance().getThreadFactory());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OptionalLiveReloadServer optionalLiveReloadServer(LiveReloadServer liveReloadServer) {
|
||||
OptionalLiveReloadServer optionalLiveReloadServer(LiveReloadServer liveReloadServer) {
|
||||
return new OptionalLiveReloadServer(liveReloadServer);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LiveReloadServerEventListener liveReloadServerEventListener(OptionalLiveReloadServer liveReloadServer) {
|
||||
LiveReloadServerEventListener liveReloadServerEventListener(OptionalLiveReloadServer liveReloadServer) {
|
||||
return new LiveReloadServerEventListener(liveReloadServer);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class LocalDevToolsAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationListener<ClassPathChangedEvent> restartingClassPathChangedEventListener(
|
||||
ApplicationListener<ClassPathChangedEvent> restartingClassPathChangedEventListener(
|
||||
FileSystemWatcherFactory fileSystemWatcherFactory) {
|
||||
return (event) -> {
|
||||
if (event.isRestartRequired()) {
|
||||
@@ -111,7 +111,7 @@ public class LocalDevToolsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory,
|
||||
ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory,
|
||||
ClassPathRestartStrategy classPathRestartStrategy) {
|
||||
URL[] urls = Restarter.getInstance().getInitialUrls();
|
||||
ClassPathFileSystemWatcher watcher = new ClassPathFileSystemWatcher(fileSystemWatcherFactory,
|
||||
@@ -122,19 +122,19 @@ public class LocalDevToolsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
return new PatternClassPathRestartStrategy(this.properties.getRestart().getAllExclude());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FileSystemWatcherFactory fileSystemWatcherFactory() {
|
||||
FileSystemWatcherFactory fileSystemWatcherFactory() {
|
||||
return this::newFileSystemWatcher;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "log-condition-evaluation-delta",
|
||||
matchIfMissing = true)
|
||||
public ConditionEvaluationDeltaLoggingListener conditionEvaluationDeltaLoggingListener() {
|
||||
ConditionEvaluationDeltaLoggingListener conditionEvaluationDeltaLoggingListener() {
|
||||
return new ConditionEvaluationDeltaLoggingListener();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,19 +102,19 @@ public class RemoteDevToolsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SourceFolderUrlFilter remoteRestartSourceFolderUrlFilter() {
|
||||
SourceFolderUrlFilter remoteRestartSourceFolderUrlFilter() {
|
||||
return new DefaultSourceFolderUrlFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public HttpRestartServer remoteRestartHttpRestartServer(SourceFolderUrlFilter sourceFolderUrlFilter) {
|
||||
HttpRestartServer remoteRestartHttpRestartServer(SourceFolderUrlFilter sourceFolderUrlFilter) {
|
||||
return new HttpRestartServer(sourceFolderUrlFilter);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
|
||||
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server, ServerProperties serverProperties,
|
||||
UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server, ServerProperties serverProperties,
|
||||
DevToolsProperties properties) {
|
||||
Servlet servlet = serverProperties.getServlet();
|
||||
RemoteDevToolsProperties remote = properties.getRemote();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -44,7 +44,7 @@ class FileSnapshot {
|
||||
this.lastModified = file.lastModified();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class FolderSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
public ChangedFiles getChangedFiles(FolderSnapshot snapshot, FileFilter triggerFilter) {
|
||||
ChangedFiles getChangedFiles(FolderSnapshot snapshot, FileFilter triggerFilter) {
|
||||
Assert.notNull(snapshot, "Snapshot must not be null");
|
||||
File folder = this.folder;
|
||||
Assert.isTrue(snapshot.folder.equals(folder), () -> "Snapshot source folder must be '" + folder + "'");
|
||||
@@ -124,7 +124,7 @@ class FolderSnapshot {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
public boolean equals(FolderSnapshot other, FileFilter filter) {
|
||||
boolean equals(FolderSnapshot other, FileFilter filter) {
|
||||
if (this.folder.equals(other.folder)) {
|
||||
Set<FileSnapshot> ourFiles = filter(this.files, filter);
|
||||
Set<FileSnapshot> otherFiles = filter(other.files, filter);
|
||||
@@ -157,7 +157,7 @@ class FolderSnapshot {
|
||||
* Return the source folder of this snapshot.
|
||||
* @return the source folder
|
||||
*/
|
||||
public File getFolder() {
|
||||
File getFolder() {
|
||||
return this.folder;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Connection {
|
||||
* Run the connection.
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
public void run() throws Exception {
|
||||
void run() throws Exception {
|
||||
if (this.header.contains("Upgrade: websocket") && this.header.contains("Sec-WebSocket-Version: 13")) {
|
||||
runWebSocket();
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class Connection {
|
||||
* Trigger livereload for the client using this connection.
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public void triggerReload() throws IOException {
|
||||
void triggerReload() throws IOException {
|
||||
if (this.webSocket) {
|
||||
logger.debug("Triggering LiveReload");
|
||||
writeWebSocketFrame(new Frame("{\"command\":\"reload\",\"path\":\"/\"}"));
|
||||
@@ -152,7 +152,7 @@ class Connection {
|
||||
* Close the connection.
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
void close() throws IOException {
|
||||
this.running = false;
|
||||
this.socket.close();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -42,7 +42,7 @@ class ConnectionInputStream extends FilterInputStream {
|
||||
* @return the HTTP header
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public String readHeader() throws IOException {
|
||||
String readHeader() throws IOException {
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
StringBuilder content = new StringBuilder(BUFFER_SIZE);
|
||||
while (content.indexOf(HEADER_END) == -1) {
|
||||
@@ -60,7 +60,7 @@ class ConnectionInputStream extends FilterInputStream {
|
||||
* @param length the amount of data to read
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public void readFully(byte[] buffer, int offset, int length) throws IOException {
|
||||
void readFully(byte[] buffer, int offset, int length) throws IOException {
|
||||
while (length > 0) {
|
||||
int amountRead = checkedRead(buffer, offset, length);
|
||||
offset += amountRead;
|
||||
@@ -74,7 +74,7 @@ class ConnectionInputStream extends FilterInputStream {
|
||||
* @return the content
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public int checkedRead() throws IOException {
|
||||
int checkedRead() throws IOException {
|
||||
int b = read();
|
||||
if (b == -1) {
|
||||
throw new IOException("End of stream");
|
||||
@@ -91,7 +91,7 @@ class ConnectionInputStream extends FilterInputStream {
|
||||
* @return the amount of data read
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public int checkedRead(byte[] buffer, int offset, int length) throws IOException {
|
||||
int checkedRead(byte[] buffer, int offset, int length) throws IOException {
|
||||
int amountRead = read(buffer, offset, length);
|
||||
if (amountRead == -1) {
|
||||
throw new IOException("End of stream");
|
||||
|
||||
@@ -39,7 +39,7 @@ class ConnectionOutputStream extends FilterOutputStream {
|
||||
this.out.write(b, off, len);
|
||||
}
|
||||
|
||||
public void writeHttp(InputStream content, String contentType) throws IOException {
|
||||
void writeHttp(InputStream content, String contentType) throws IOException {
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(content);
|
||||
writeHeaders("HTTP/1.1 200 OK", "Content-Type: " + contentType, "Content-Length: " + bytes.length,
|
||||
"Connection: close");
|
||||
@@ -47,7 +47,7 @@ class ConnectionOutputStream extends FilterOutputStream {
|
||||
flush();
|
||||
}
|
||||
|
||||
public void writeHeaders(String... headers) throws IOException {
|
||||
void writeHeaders(String... headers) throws IOException {
|
||||
StringBuilder response = new StringBuilder();
|
||||
for (String header : headers) {
|
||||
response.append(header).append("\r\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -56,11 +56,11 @@ class Frame {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public byte[] getPayload() {
|
||||
byte[] getPayload() {
|
||||
return this.payload;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class Frame {
|
||||
return new String(this.payload);
|
||||
}
|
||||
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
void write(OutputStream outputStream) throws IOException {
|
||||
outputStream.write(0x80 | this.type.code);
|
||||
if (this.payload.length < 126) {
|
||||
outputStream.write(0x00 | (this.payload.length & 0x7F));
|
||||
@@ -83,7 +83,7 @@ class Frame {
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
public static Frame read(ConnectionInputStream inputStream) throws IOException {
|
||||
static Frame read(ConnectionInputStream inputStream) throws IOException {
|
||||
int firstByte = inputStream.checkedRead();
|
||||
Assert.state((firstByte & 0x80) != 0, "Fragmented frames are not supported");
|
||||
int maskAndLength = inputStream.checkedRead();
|
||||
@@ -110,7 +110,7 @@ class Frame {
|
||||
/**
|
||||
* Frame types.
|
||||
*/
|
||||
public enum Type {
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* Continuation frame.
|
||||
@@ -148,7 +148,7 @@ class Frame {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public static Type forCode(int code) {
|
||||
static Type forCode(int code) {
|
||||
for (Type type : values()) {
|
||||
if (type.code == code) {
|
||||
return type;
|
||||
|
||||
@@ -148,13 +148,13 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
@Bean
|
||||
@RestartScope
|
||||
@ConditionalOnMissingBean
|
||||
public LiveReloadServer liveReloadServer() {
|
||||
LiveReloadServer liveReloadServer() {
|
||||
return new LiveReloadServer(this.properties.getLivereload().getPort(),
|
||||
Restarter.getInstance().getThreadFactory());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationListener<ClassPathChangedEvent> liveReloadTriggeringClassPathChangedEventListener(
|
||||
ApplicationListener<ClassPathChangedEvent> liveReloadTriggeringClassPathChangedEventListener(
|
||||
OptionalLiveReloadServer optionalLiveReloadServer) {
|
||||
return (event) -> {
|
||||
String url = this.remoteUrl + this.properties.getRemote().getContextPath();
|
||||
@@ -164,7 +164,7 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OptionalLiveReloadServer optionalLiveReloadServer() {
|
||||
OptionalLiveReloadServer optionalLiveReloadServer() {
|
||||
return new OptionalLiveReloadServer(this.liveReloadServer);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
private String remoteUrl;
|
||||
|
||||
@Bean
|
||||
public ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory,
|
||||
ClassPathFileSystemWatcher classPathFileSystemWatcher(FileSystemWatcherFactory fileSystemWatcherFactory,
|
||||
ClassPathRestartStrategy classPathRestartStrategy) {
|
||||
DefaultRestartInitializer restartInitializer = new DefaultRestartInitializer();
|
||||
URL[] urls = restartInitializer.getInitialUrls(Thread.currentThread());
|
||||
@@ -199,7 +199,7 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FileSystemWatcherFactory getFileSystemWatcherFactory() {
|
||||
FileSystemWatcherFactory getFileSystemWatcherFactory() {
|
||||
return this::newFileSystemWatcher;
|
||||
}
|
||||
|
||||
@@ -215,12 +215,12 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
ClassPathRestartStrategy classPathRestartStrategy() {
|
||||
return new PatternClassPathRestartStrategy(this.properties.getRestart().getAllExclude());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClassPathChangeUploader classPathChangeUploader(ClientHttpRequestFactory requestFactory) {
|
||||
ClassPathChangeUploader classPathChangeUploader(ClientHttpRequestFactory requestFactory) {
|
||||
String url = this.remoteUrl + this.properties.getRemote().getContextPath() + "/restart";
|
||||
return new ClassPathChangeUploader(url, requestFactory);
|
||||
}
|
||||
|
||||
@@ -73,15 +73,15 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||
return this.urls.iterator();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
int size() {
|
||||
return this.urls.size();
|
||||
}
|
||||
|
||||
public URL[] toArray() {
|
||||
URL[] toArray() {
|
||||
return this.urls.toArray(new URL[0]);
|
||||
}
|
||||
|
||||
public List<URL> toList() {
|
||||
List<URL> toList() {
|
||||
return Collections.unmodifiableList(this.urls);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||
return this.urls.toString();
|
||||
}
|
||||
|
||||
public static ChangeableUrls fromClassLoader(ClassLoader classLoader) {
|
||||
static ChangeableUrls fromClassLoader(ClassLoader classLoader) {
|
||||
List<URL> urls = new ArrayList<>();
|
||||
for (URL url : urlsFromClassLoader(classLoader)) {
|
||||
urls.add(url);
|
||||
@@ -171,11 +171,11 @@ final class ChangeableUrls implements Iterable<URL> {
|
||||
return urls;
|
||||
}
|
||||
|
||||
public static ChangeableUrls fromUrls(Collection<URL> urls) {
|
||||
static ChangeableUrls fromUrls(Collection<URL> urls) {
|
||||
return fromUrls(new ArrayList<>(urls).toArray(new URL[urls.size()]));
|
||||
}
|
||||
|
||||
public static ChangeableUrls fromUrls(URL... urls) {
|
||||
static ChangeableUrls fromUrls(URL... urls) {
|
||||
return new ChangeableUrls(urls);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ final class ClassLoaderFilesResourcePatternResolver implements ResourcePatternRe
|
||||
*/
|
||||
private static class ResourcePatternResolverFactory {
|
||||
|
||||
public ResourcePatternResolver getResourcePatternResolver(ApplicationContext applicationContext,
|
||||
ResourcePatternResolver getResourcePatternResolver(ApplicationContext applicationContext,
|
||||
ResourceLoader resourceLoader) {
|
||||
if (resourceLoader == null) {
|
||||
resourceLoader = new DefaultResourceLoader();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -69,7 +69,7 @@ class MainMethod {
|
||||
* Returns the actual main method.
|
||||
* @return the main method
|
||||
*/
|
||||
public Method getMethod() {
|
||||
Method getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class MainMethod {
|
||||
* Return the name of the declaring class.
|
||||
* @return the declaring class name
|
||||
*/
|
||||
public String getDeclaringClassName() {
|
||||
String getDeclaringClassName() {
|
||||
return this.method.getDeclaringClass().getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -54,7 +54,7 @@ class RestartLauncher extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
public Throwable getError() {
|
||||
Throwable getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
|
||||
@@ -600,13 +600,13 @@ public class Restarter {
|
||||
setDaemon(false);
|
||||
}
|
||||
|
||||
public void call(Callable<?> callable) {
|
||||
void call(Callable<?> callable) {
|
||||
this.callable = callable;
|
||||
start();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <V> V callAndWait(Callable<V> callable) {
|
||||
<V> V callAndWait(Callable<V> callable) {
|
||||
this.callable = callable;
|
||||
start();
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -78,7 +78,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void setup(Thread thread) {
|
||||
static void setup(Thread thread) {
|
||||
UncaughtExceptionHandler handler = thread.getUncaughtExceptionHandler();
|
||||
if (!(handler instanceof SilentExitExceptionHandler)) {
|
||||
handler = new SilentExitExceptionHandler(handler);
|
||||
@@ -86,7 +86,7 @@ class SilentExitExceptionHandler implements UncaughtExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void exitCurrentThread() {
|
||||
static void exitCurrentThread() {
|
||||
throw new SilentExitException();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -31,23 +31,23 @@ class TunnelClientListeners {
|
||||
|
||||
private final List<TunnelClientListener> listeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
public void addListener(TunnelClientListener listener) {
|
||||
void addListener(TunnelClientListener listener) {
|
||||
Assert.notNull(listener, "Listener must not be null");
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(TunnelClientListener listener) {
|
||||
void removeListener(TunnelClientListener listener) {
|
||||
Assert.notNull(listener, "Listener must not be null");
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void fireOpenEvent(SocketChannel socket) {
|
||||
void fireOpenEvent(SocketChannel socket) {
|
||||
for (TunnelClientListener listener : this.listeners) {
|
||||
listener.onOpen(socket);
|
||||
}
|
||||
}
|
||||
|
||||
public void fireCloseEvent(SocketChannel socket) {
|
||||
void fireCloseEvent(SocketChannel socket) {
|
||||
for (TunnelClientListener listener : this.listeners) {
|
||||
listener.onClose(socket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user