5959 */
6060public class NotionDatabaseItemReader <T > extends AbstractPaginatedDataItemReader <T > {
6161
62- private static final String DEFAULT_BASE_URL = "https://api.notion.com/v1" ;
63-
6462 private static final int DEFAULT_PAGE_SIZE = 100 ;
6563
64+ private static final String DEFAULT_BASE_URL = "https://api.notion.com/v1" ;
65+
6666 private final String token ;
6767
6868 private final String databaseId ;
6969
7070 private final PropertyMapper <T > propertyMapper ;
7171
72- private String baseUrl ;
72+ private String baseUrl = DEFAULT_BASE_URL ;
7373
7474 private @ Nullable QueryTopLevelFilter filter ;
7575
@@ -82,22 +82,17 @@ public class NotionDatabaseItemReader<T> extends AbstractPaginatedDataItemReader
8282 private @ Nullable String nextCursor ;
8383
8484 /**
85- * Create a new {@link NotionDatabaseItemReader} with the following defaults:
86- * <ul>
87- * <li>{@code baseUrl} = {@value #DEFAULT_BASE_URL}</li>
88- * <li>{@code pageSize} = {@value #DEFAULT_PAGE_SIZE}</li>
89- * </ul>
85+ * Create a new {@link NotionDatabaseItemReader}.
9086 * @param token the Notion integration token
9187 * @param databaseId UUID of the database to read from
9288 * @param propertyMapper the {@link PropertyMapper} responsible for mapping Notion
9389 * item properties into a Java object
9490 */
9591 public NotionDatabaseItemReader (String token , String databaseId , PropertyMapper <T > propertyMapper ) {
96- this .baseUrl = DEFAULT_BASE_URL ;
97- this .pageSize = DEFAULT_PAGE_SIZE ;
9892 this .token = Objects .requireNonNull (token );
9993 this .databaseId = Objects .requireNonNull (databaseId );
10094 this .propertyMapper = Objects .requireNonNull (propertyMapper );
95+ setPageSize (DEFAULT_PAGE_SIZE );
10196 }
10297
10398 /**
@@ -151,6 +146,19 @@ public void setPageSize(int pageSize) {
151146 super .setPageSize (pageSize );
152147 }
153148
149+ /**
150+ * {@inheritDoc}
151+ */
152+ @ Override
153+ protected void doOpen () {
154+ client = new NotionClient (token );
155+ client .setHttpClient (new JavaNetHttpClient ());
156+ client .setLogger (new Slf4jLogger ());
157+ client .setBaseUrl (baseUrl );
158+
159+ hasMore = true ;
160+ }
161+
154162 /**
155163 * {@inheritDoc}
156164 */
@@ -175,7 +183,7 @@ protected Iterator<T> doPageRead() {
175183 return queryResults .getResults ()
176184 .stream ()
177185 .map (NotionDatabaseItemReader ::getProperties )
178- .map (properties -> propertyMapper . map ( properties ) )
186+ .map (propertyMapper :: map )
179187 .iterator ();
180188 }
181189
@@ -198,19 +206,6 @@ private static String getPlainText(List<RichText> texts) {
198206 return texts .isEmpty () ? "" : texts .get (0 ).getPlainText ();
199207 }
200208
201- /**
202- * {@inheritDoc}
203- */
204- @ Override
205- protected void doOpen () {
206- client = new NotionClient (token );
207- client .setHttpClient (new JavaNetHttpClient ());
208- client .setLogger (new Slf4jLogger ());
209- client .setBaseUrl (baseUrl );
210-
211- hasMore = true ;
212- }
213-
214209 /**
215210 * {@inheritDoc}
216211 */
0 commit comments