Use consistent class design
Update all classes so that inner classes are always last. Also ensure that utility classes are always final and have a private constructor and make exceptions final whenever possible. Issue: SPR-16968
This commit is contained in:
committed by
Juergen Hoeller
parent
0ad0f341bd
commit
eeebd51f57
@@ -52,7 +52,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private final HttpMethod httpMethod;
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ public class SimpleNamingContext implements Context {
|
||||
}
|
||||
|
||||
|
||||
private static class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {
|
||||
private static final class NameClassPairEnumeration extends AbstractNamingEnumeration<NameClassPair> {
|
||||
|
||||
private NameClassPairEnumeration(SimpleNamingContext context, String root) throws NamingException {
|
||||
super(context, root);
|
||||
@@ -370,7 +370,7 @@ public class SimpleNamingContext implements Context {
|
||||
}
|
||||
|
||||
|
||||
private static class BindingEnumeration extends AbstractNamingEnumeration<Binding> {
|
||||
private static final class BindingEnumeration extends AbstractNamingEnumeration<Binding> {
|
||||
|
||||
private BindingEnumeration(SimpleNamingContext context, String root) throws NamingException {
|
||||
super(context, root);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MockFilterChain implements FilterChain {
|
||||
/**
|
||||
* A filter that simply delegates to a Servlet.
|
||||
*/
|
||||
private static class ServletFilterProxy implements Filter {
|
||||
private static final class ServletFilterProxy implements Filter {
|
||||
|
||||
private final Servlet delegateServlet;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* @author Arjen Poutsma
|
||||
* @since 5.0
|
||||
*/
|
||||
public class MockServerRequest implements ServerRequest {
|
||||
public final class MockServerRequest implements ServerRequest {
|
||||
|
||||
private final HttpMethod method;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.util.Assert;
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SystemProfileValueSource implements ProfileValueSource {
|
||||
public final class SystemProfileValueSource implements ProfileValueSource {
|
||||
|
||||
private static final SystemProfileValueSource INSTANCE = new SystemProfileValueSource();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -26,7 +26,12 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
*/
|
||||
public class TestAnnotationUtils {
|
||||
public final class TestAnnotationUtils {
|
||||
|
||||
|
||||
private TestAnnotationUtils() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the {@code timeout} configured via the {@link Timed @Timed}
|
||||
|
||||
@@ -38,7 +38,12 @@ import org.springframework.util.Assert;
|
||||
* @since 4.1
|
||||
* @see TransactionalTestExecutionListener
|
||||
*/
|
||||
public class TestTransaction {
|
||||
public final class TestTransaction {
|
||||
|
||||
|
||||
private TestTransaction() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether a test-managed transaction is currently <em>active</em>.
|
||||
|
||||
@@ -25,12 +25,16 @@ import org.springframework.lang.Nullable;
|
||||
* @author Sam Brannen
|
||||
* @since 4.1
|
||||
*/
|
||||
class TransactionContextHolder {
|
||||
final class TransactionContextHolder {
|
||||
|
||||
private static final ThreadLocal<TransactionContext> currentTransactionContext =
|
||||
new NamedInheritableThreadLocal<>("Test Transaction Context");
|
||||
|
||||
|
||||
private TransactionContextHolder() {
|
||||
}
|
||||
|
||||
|
||||
static void setCurrentTransactionContext(TransactionContext transactionContext) {
|
||||
currentTransactionContext.set(transactionContext);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -38,11 +38,15 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
|
||||
* @see org.springframework.jdbc.datasource.init.DatabasePopulatorUtils
|
||||
*/
|
||||
public class JdbcTestUtils {
|
||||
public final class JdbcTestUtils {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(JdbcTestUtils.class);
|
||||
|
||||
|
||||
private JdbcTestUtils() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count the rows in the given table.
|
||||
* @param jdbcTemplate the JdbcTemplate with which to perform JDBC operations
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.3
|
||||
*/
|
||||
public class ExpectedCount {
|
||||
public final class ExpectedCount {
|
||||
|
||||
private final int minCount;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.web.client.support.RestGatewaySupport;
|
||||
* @since 3.2
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MockRestServiceServer {
|
||||
public final class MockRestServiceServer {
|
||||
|
||||
private final RequestExpectationManager expectationManager;
|
||||
|
||||
|
||||
@@ -33,7 +33,12 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
* @see #webAppContextSetup(WebApplicationContext)
|
||||
* @see #standaloneSetup(Object...)
|
||||
*/
|
||||
public class MockMvcBuilders {
|
||||
public final class MockMvcBuilders {
|
||||
|
||||
|
||||
private MockMvcBuilders() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a {@link MockMvc} instance using the given, fully initialized
|
||||
|
||||
Reference in New Issue
Block a user