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
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user