Skip to content

Commit 2c0616b

Browse files
authored
Merge pull request #380 from kazuki43zoo/variable-length-argument
Change to Variable-length argument from array argument on SqlSessionFactoryBean
2 parents 5f74485 + 1fafc59 commit 2c0616b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void setCache(Cache cache) {
231231
* list of plugins
232232
*
233233
*/
234-
public void setPlugins(Interceptor[] plugins) {
234+
public void setPlugins(Interceptor... plugins) {
235235
this.plugins = plugins;
236236
}
237237

@@ -289,7 +289,7 @@ public void setTypeHandlersPackage(String typeHandlersPackage) {
289289
* @param typeHandlers
290290
* Type handler list
291291
*/
292-
public void setTypeHandlers(TypeHandler<?>[] typeHandlers) {
292+
public void setTypeHandlers(TypeHandler<?>... typeHandlers) {
293293
this.typeHandlers = typeHandlers;
294294
}
295295

@@ -301,7 +301,7 @@ public void setTypeHandlers(TypeHandler<?>[] typeHandlers) {
301301
* @param typeAliases
302302
* Type aliases list
303303
*/
304-
public void setTypeAliases(Class<?>[] typeAliases) {
304+
public void setTypeAliases(Class<?>... typeAliases) {
305305
this.typeAliases = typeAliases;
306306
}
307307

@@ -351,7 +351,7 @@ public void setConfiguration(Configuration configuration) {
351351
* @param mapperLocations
352352
* location of MyBatis mapper files
353353
*/
354-
public void setMapperLocations(Resource[] mapperLocations) {
354+
public void setMapperLocations(Resource... mapperLocations) {
355355
this.mapperLocations = mapperLocations;
356356
}
357357

src/test/java/org/mybatis/spring/AbstractMyBatisSpringTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public abstract class AbstractMyBatisSpringTest {
5353
public static void setupBase() throws Exception {
5454
// create an SqlSessionFactory that will use SpringManagedTransactions
5555
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
56-
factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") });
56+
factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml"));
5757
// note running without SqlSessionFactoryBean.configLocation set => default configuration
5858
factoryBean.setDataSource(dataSource);
59-
factoryBean.setPlugins(new Interceptor[] { executorInterceptor });
59+
factoryBean.setPlugins(executorInterceptor);
6060

6161
exceptionTranslator = new MyBatisExceptionTranslator(dataSource, true);
6262

src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void testSpecifyConfigurationAndConfigLocation() throws Exception {
301301
void testFragmentsAreReadWithMapperLocations() throws Exception {
302302
setupFactoryBean();
303303

304-
factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") });
304+
factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml"));
305305

306306
SqlSessionFactory factory = factoryBean.getObject();
307307

@@ -321,7 +321,7 @@ void testNullMapperLocations() throws Exception {
321321
@Test
322322
void testEmptyMapperLocations() throws Exception {
323323
setupFactoryBean();
324-
factoryBean.setMapperLocations(new org.springframework.core.io.Resource[0]);
324+
factoryBean.setMapperLocations();
325325

326326
assertDefaultConfig(factoryBean.getObject());
327327
}
@@ -337,7 +337,7 @@ void testMapperLocationsWithNullEntry() throws Exception {
337337
@Test
338338
void testAddATypeHandler() throws Exception {
339339
setupFactoryBean();
340-
factoryBean.setTypeHandlers(new TypeHandler[] { new DummyTypeHandler() });
340+
factoryBean.setTypeHandlers(new DummyTypeHandler());
341341

342342
TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry();
343343
assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue();
@@ -347,7 +347,7 @@ void testAddATypeHandler() throws Exception {
347347
void testAddATypeAlias() throws Exception {
348348
setupFactoryBean();
349349

350-
factoryBean.setTypeAliases(new Class[] { DummyTypeAlias.class });
350+
factoryBean.setTypeAliases(DummyTypeAlias.class);
351351
TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry();
352352
typeAliasRegistry.resolveAlias("testAlias");
353353
}

src/test/java/org/mybatis/spring/mapper/MapperFactoryBeanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void testAddToConfigTrue() throws Exception {
6464
factoryBean.setDatabaseIdProvider(null);
6565
// mapperLocations properties defaults to null
6666
factoryBean.setDataSource(dataSource);
67-
factoryBean.setPlugins(new Interceptor[] { executorInterceptor });
67+
factoryBean.setPlugins(executorInterceptor);
6868

6969
SqlSessionFactory sqlSessionFactory = factoryBean.getObject();
7070

src/test/java/org/mybatis/spring/sample/config/SampleConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public PlatformTransactionManager transactionalManager() {
5050
public SqlSessionFactory sqlSessionFactory() throws Exception {
5151
SqlSessionFactoryBean ss = new SqlSessionFactoryBean();
5252
ss.setDataSource(dataSource());
53-
ss.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml") });
53+
ss.setMapperLocations(new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml"));
5454
return ss.getObject();
5555
}
5656

0 commit comments

Comments
 (0)