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:
Phillip Webb
2018-06-20 19:44:39 -07:00
committed by Juergen Hoeller
parent 0ad0f341bd
commit eeebd51f57
128 changed files with 656 additions and 455 deletions

View File

@@ -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.
@@ -34,7 +34,7 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException;
@SuppressWarnings("serial")
public class BadSqlGrammarException extends InvalidDataAccessResourceUsageException {
private String sql;
private final String sql;
/**

View File

@@ -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.
@@ -29,9 +29,9 @@ import org.springframework.dao.DataRetrievalFailureException;
@SuppressWarnings("serial")
public class IncorrectResultSetColumnCountException extends DataRetrievalFailureException {
private int expectedCount;
private final int expectedCount;
private int actualCount;
private final int actualCount;
/**

View File

@@ -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.
@@ -37,7 +37,7 @@ import org.springframework.lang.Nullable;
public class InvalidResultSetAccessException extends InvalidDataAccessResourceUsageException {
@Nullable
private String sql;
private final String sql;
/**
@@ -57,6 +57,7 @@ public class InvalidResultSetAccessException extends InvalidDataAccessResourceUs
*/
public InvalidResultSetAccessException(SQLException ex) {
super(ex.getMessage(), ex);
this.sql = null;
}

View File

@@ -30,10 +30,10 @@ import org.springframework.dao.IncorrectUpdateSemanticsDataAccessException;
public class JdbcUpdateAffectedIncorrectNumberOfRowsException extends IncorrectUpdateSemanticsDataAccessException {
/** Number of rows that should have been affected. */
private int expected;
private final int expected;
/** Number of rows that actually were affected. */
private int actual;
private final int actual;
/**

View File

@@ -38,7 +38,12 @@ import org.springframework.util.xml.DomUtils;
* @author Stephane Nicoll
* @since 3.1
*/
class DatabasePopulatorConfigUtils {
final class DatabasePopulatorConfigUtils {
private DatabasePopulatorConfigUtils() {
}
public static void setDatabasePopulator(Element element, BeanDefinitionBuilder builder) {
List<Element> scripts = DomUtils.getChildElementsByTagName(element, "script");

View File

@@ -35,7 +35,7 @@ import org.springframework.jdbc.support.MetaDataAccessException;
* @author Juergen Hoeller
* @since 2.5
*/
public class CallMetaDataProviderFactory {
public final class CallMetaDataProviderFactory {
/** List of supported database products for procedure calls. */
public static final List<String> supportedDatabaseProductsForProcedures = Arrays.asList(
@@ -59,6 +59,10 @@ public class CallMetaDataProviderFactory {
private static final Log logger = LogFactory.getLog(CallMetaDataProviderFactory.class);
private CallMetaDataProviderFactory() {
}
/**
* Create a {@link CallMetaDataProvider} based on the database meta-data.
* @param dataSource the JDBC DataSource to use for retrieving meta-data

View File

@@ -32,11 +32,15 @@ import org.springframework.jdbc.support.MetaDataAccessException;
* @author Thomas Risberg
* @since 2.5
*/
public class TableMetaDataProviderFactory {
public final class TableMetaDataProviderFactory {
private static final Log logger = LogFactory.getLog(TableMetaDataProviderFactory.class);
private TableMetaDataProviderFactory() {
}
/**
* Create a {@link TableMetaDataProvider} based on the database meta-data.
* @param dataSource used to retrieve meta-data

View File

@@ -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.
@@ -202,7 +202,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource {
/**
* Inner class used as ThreadLocal value.
*/
private static class JdbcUserCredentials {
private static final class JdbcUserCredentials {
public final String username;

View File

@@ -29,6 +29,11 @@ import org.springframework.util.Assert;
*/
final class EmbeddedDatabaseConfigurerFactory {
private EmbeddedDatabaseConfigurerFactory() {
}
/**
* Return a configurer instance for the given embedded database type.
* @param type the embedded database type (HSQL, H2 or Derby)

View File

@@ -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,12 @@ import java.io.OutputStream;
* @author Juergen Hoeller
* @since 3.0
*/
public class OutputStreamFactory {
public final class OutputStreamFactory {
private OutputStreamFactory() {
}
/**
* Returns an {@link java.io.OutputStream} that ignores all data given to it.

View File

@@ -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.
@@ -33,7 +33,7 @@ import org.springframework.lang.Nullable;
* @since 3.1.1
* @see SQLErrorCodesFactory
*/
public class CustomSQLExceptionTranslatorRegistry {
public final class CustomSQLExceptionTranslatorRegistry {
private static final Log logger = LogFactory.getLog(CustomSQLExceptionTranslatorRegistry.class);