Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between getters and setters in order to be able to provide beans with properties with a common type when type safety is taken in account like with Kotlin. It also add a few missing property level @Nullable annotations. Issue: SPR-15792
This commit is contained in:
@@ -143,7 +143,7 @@ public class CallMetaDataContext {
|
||||
/**
|
||||
* Specify the name of the procedure.
|
||||
*/
|
||||
public void setProcedureName(String procedureName) {
|
||||
public void setProcedureName(@Nullable String procedureName) {
|
||||
this.procedureName = procedureName;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class CallMetaDataContext {
|
||||
/**
|
||||
* Specify the name of the catalog.
|
||||
*/
|
||||
public void setCatalogName(String catalogName) {
|
||||
public void setCatalogName(@Nullable String catalogName) {
|
||||
this.catalogName = catalogName;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class CallMetaDataContext {
|
||||
/**
|
||||
* Secify the name of the schema.
|
||||
*/
|
||||
public void setSchemaName(String schemaName) {
|
||||
public void setSchemaName(@Nullable String schemaName) {
|
||||
this.schemaName = schemaName;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TableMetaDataContext {
|
||||
/**
|
||||
* Set the name of the table for this context.
|
||||
*/
|
||||
public void setTableName(String tableName) {
|
||||
public void setTableName(@Nullable String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TableMetaDataContext {
|
||||
/**
|
||||
* Set the name of the catalog for this context.
|
||||
*/
|
||||
public void setCatalogName(String catalogName) {
|
||||
public void setCatalogName(@Nullable String catalogName) {
|
||||
this.catalogName = catalogName;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TableMetaDataContext {
|
||||
/**
|
||||
* Set the name of the schema for this context.
|
||||
*/
|
||||
public void setSchemaName(String schemaName) {
|
||||
public void setSchemaName(@Nullable String schemaName) {
|
||||
this.schemaName = schemaName;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class AbstractJdbcCall {
|
||||
/**
|
||||
* Set the name of the stored procedure.
|
||||
*/
|
||||
public void setProcedureName(String procedureName) {
|
||||
public void setProcedureName(@Nullable String procedureName) {
|
||||
this.callMetaDataContext.setProcedureName(procedureName);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public abstract class AbstractJdbcCall {
|
||||
/**
|
||||
* Set the catalog name to use.
|
||||
*/
|
||||
public void setCatalogName(String catalogName) {
|
||||
public void setCatalogName(@Nullable String catalogName) {
|
||||
this.callMetaDataContext.setCatalogName(catalogName);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public abstract class AbstractJdbcCall {
|
||||
/**
|
||||
* Set the schema name to use.
|
||||
*/
|
||||
public void setSchemaName(String schemaName) {
|
||||
public void setSchemaName(@Nullable String schemaName) {
|
||||
this.callMetaDataContext.setSchemaName(schemaName);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractJdbcInsert {
|
||||
/**
|
||||
* Set the name of the table for this insert.
|
||||
*/
|
||||
public void setTableName(String tableName) {
|
||||
public void setTableName(@Nullable String tableName) {
|
||||
checkIfConfigurationModificationIsAllowed();
|
||||
this.tableMetaDataContext.setTableName(tableName);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public abstract class AbstractJdbcInsert {
|
||||
/**
|
||||
* Set the name of the schema for this insert.
|
||||
*/
|
||||
public void setSchemaName(String schemaName) {
|
||||
public void setSchemaName(@Nullable String schemaName) {
|
||||
checkIfConfigurationModificationIsAllowed();
|
||||
this.tableMetaDataContext.setSchemaName(schemaName);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public abstract class AbstractJdbcInsert {
|
||||
/**
|
||||
* Set the name of the catalog for this insert.
|
||||
*/
|
||||
public void setCatalogName(String catalogName) {
|
||||
public void setCatalogName(@Nullable String catalogName) {
|
||||
checkIfConfigurationModificationIsAllowed();
|
||||
this.tableMetaDataContext.setCatalogName(catalogName);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class JdbcDaoSupport extends DaoSupport {
|
||||
* Set the JdbcTemplate for this DAO explicitly,
|
||||
* as an alternative to specifying a DataSource.
|
||||
*/
|
||||
public final void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
public final void setJdbcTemplate(@Nullable JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
initTemplateConfig();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* Set the JDBC URL to use for connecting through the Driver.
|
||||
* @see java.sql.Driver#connect(String, java.util.Properties)
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
public void setUrl(@Nullable String url) {
|
||||
Assert.hasText(url, "Property 'url' must not be empty");
|
||||
this.url = url.trim();
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* Set the JDBC username to use for connecting through the Driver.
|
||||
* @see java.sql.Driver#connect(String, java.util.Properties)
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
public void setUsername(@Nullable String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* Set the JDBC password to use for connecting through the Driver.
|
||||
* @see java.sql.Driver#connect(String, java.util.Properties)
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(@Nullable String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* @since 4.3.2
|
||||
* @see Connection#setCatalog
|
||||
*/
|
||||
public void setCatalog(String catalog) {
|
||||
public void setCatalog(@Nullable String catalog) {
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* @since 4.3.2
|
||||
* @see Connection#setSchema
|
||||
*/
|
||||
public void setSchema(String schema) {
|
||||
public void setSchema(@Nullable String schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
|
||||
* DataSource will override the corresponding connection properties.
|
||||
* @see java.sql.Driver#connect(String, java.util.Properties)
|
||||
*/
|
||||
public void setConnectionProperties(Properties connectionProperties) {
|
||||
public void setConnectionProperties(@Nullable Properties connectionProperties) {
|
||||
this.connectionProperties = connectionProperties;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
|
||||
* @see TransactionAwareDataSourceProxy
|
||||
* @see org.springframework.transaction.jta.JtaTransactionManager
|
||||
*/
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
public void setDataSource(@Nullable DataSource dataSource) {
|
||||
if (dataSource instanceof TransactionAwareDataSourceProxy) {
|
||||
// If we got a TransactionAwareDataSourceProxy, we need to perform transactions
|
||||
// for its underlying target DataSource, else data access code won't see
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class DelegatingDataSource implements DataSource, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private DataSource targetDataSource;
|
||||
|
||||
|
||||
@@ -62,8 +63,7 @@ public class DelegatingDataSource implements DataSource, InitializingBean {
|
||||
/**
|
||||
* Set the target DataSource that this DataSource should delegate to.
|
||||
*/
|
||||
public void setTargetDataSource(DataSource targetDataSource) {
|
||||
Assert.notNull(targetDataSource, "'targetDataSource' must not be null");
|
||||
public void setTargetDataSource(@Nullable DataSource targetDataSource) {
|
||||
this.targetDataSource = targetDataSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private SQLExceptionTranslator fallbackTranslator;
|
||||
|
||||
|
||||
@@ -45,7 +46,7 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
|
||||
* Override the default SQL state fallback translator
|
||||
* (typically a {@link SQLStateSQLExceptionTranslator}).
|
||||
*/
|
||||
public void setFallbackTranslator(SQLExceptionTranslator fallback) {
|
||||
public void setFallbackTranslator(@Nullable SQLExceptionTranslator fallback) {
|
||||
this.fallbackTranslator = fallback;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ public class CustomSQLErrorCodesTranslation {
|
||||
/**
|
||||
* Set the exception class for the specified error codes.
|
||||
*/
|
||||
public void setExceptionClass(Class<?> exceptionClass) {
|
||||
if (!DataAccessException.class.isAssignableFrom(exceptionClass)) {
|
||||
public void setExceptionClass(@Nullable Class<?> exceptionClass) {
|
||||
if (exceptionClass != null && !DataAccessException.class.isAssignableFrom(exceptionClass)) {
|
||||
throw new IllegalArgumentException("Invalid exception class [" + exceptionClass +
|
||||
"]: needs to be a subclass of [org.springframework.dao.DataAccessException]");
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class JdbcAccessor implements InitializingBean {
|
||||
/**
|
||||
* Set the JDBC DataSource to obtain connections from.
|
||||
*/
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
public void setDataSource(@Nullable DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
|
||||
* Set custom error codes to be used for translation.
|
||||
* @param sec custom error codes to use
|
||||
*/
|
||||
public void setSqlErrorCodes(SQLErrorCodes sec) {
|
||||
public void setSqlErrorCodes(@Nullable SQLErrorCodes sec) {
|
||||
this.sqlErrorCodes = sec;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SQLErrorCodes {
|
||||
* Set this property if the database name contains spaces,
|
||||
* in which case we can not use the bean name for lookup.
|
||||
*/
|
||||
public void setDatabaseProductName(String databaseProductName) {
|
||||
public void setDatabaseProductName(@Nullable String databaseProductName) {
|
||||
this.databaseProductNames = new String[] {databaseProductName};
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class SQLErrorCodes {
|
||||
* Set this property to specify multiple database names that contains spaces,
|
||||
* in which case we can not use bean names for lookup.
|
||||
*/
|
||||
public void setDatabaseProductNames(String... databaseProductNames) {
|
||||
public void setDatabaseProductNames(@Nullable String... databaseProductNames) {
|
||||
this.databaseProductNames = databaseProductNames;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class SQLErrorCodes {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomSqlExceptionTranslator(SQLExceptionTranslator customSqlExceptionTranslator) {
|
||||
public void setCustomSqlExceptionTranslator(@Nullable SQLExceptionTranslator customSqlExceptionTranslator) {
|
||||
this.customSqlExceptionTranslator = customSqlExceptionTranslator;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user