Skip to content

Commit bb337c6

Browse files
Ditscheridoufmbenhassine
authored andcommitted
Change visibility of properties to protected in JdbcPagingItemReaderBuilder
There are cases, when you want to extend the JdbcPagingItemReader by adding some custom fields and behaviours, but want to stay in the normal way of creating this class via a Builder class. If you want to do it, you currently have to reimplement the whole class just for adding some fields because there is no non-ugly way to access the fields. This commit makes those properties protected, so one can override the default build() method behaviour in the derived class and still have access to the properties. Issue #4331
1 parent 21bc4d5 commit bb337c6

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilder.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2022 the original author or authors.
2+
* Copyright 2017-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,33 +56,33 @@
5656
*/
5757
public class JdbcPagingItemReaderBuilder<T> {
5858

59-
private DataSource dataSource;
59+
protected DataSource dataSource;
6060

61-
private int fetchSize = JdbcPagingItemReader.VALUE_NOT_SET;
61+
protected int fetchSize = JdbcPagingItemReader.VALUE_NOT_SET;
6262

63-
private PagingQueryProvider queryProvider;
63+
protected PagingQueryProvider queryProvider;
6464

65-
private RowMapper<T> rowMapper;
65+
protected RowMapper<T> rowMapper;
6666

67-
private Map<String, Object> parameterValues;
67+
protected Map<String, Object> parameterValues;
6868

69-
private int pageSize = 10;
69+
protected int pageSize = 10;
7070

71-
private String groupClause;
71+
protected String groupClause;
7272

73-
private String selectClause;
73+
protected String selectClause;
7474

75-
private String fromClause;
75+
protected String fromClause;
7676

77-
private String whereClause;
77+
protected String whereClause;
7878

79-
private Map<String, Order> sortKeys;
79+
protected Map<String, Order> sortKeys;
8080

81-
private boolean saveState = true;
81+
protected boolean saveState = true;
8282

83-
private String name;
83+
protected String name;
8484

85-
private int maxItemCount = Integer.MAX_VALUE;
85+
protected int maxItemCount = Integer.MAX_VALUE;
8686

8787
private int currentItemCount;
8888

@@ -329,7 +329,7 @@ public JdbcPagingItemReader<T> build() {
329329
return reader;
330330
}
331331

332-
private PagingQueryProvider determineQueryProvider(DataSource dataSource) {
332+
protected PagingQueryProvider determineQueryProvider(DataSource dataSource) {
333333

334334
try {
335335
DatabaseType databaseType = DatabaseType.fromMetaData(dataSource);
@@ -394,5 +394,4 @@ private PagingQueryProvider determineQueryProvider(DataSource dataSource) {
394394
throw new IllegalArgumentException("Unable to determine PagingQueryProvider type", e);
395395
}
396396
}
397-
398397
}

0 commit comments

Comments
 (0)