Skip to content

Commit a30aaac

Browse files
committed
Improve generic type handling in RepositoryItemReader
1 parent 5ba363c commit a30aaac

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -76,13 +76,14 @@
7676
*
7777
* @author Michael Minella
7878
* @author Antoine Kapps
79+
* @author Mahmoud Ben Hassine
7980
* @since 2.2
8081
*/
8182
public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements InitializingBean {
8283

8384
protected Log logger = LogFactory.getLog(getClass());
8485

85-
private PagingAndSortingRepository<?, ?> repository;
86+
private PagingAndSortingRepository<T, ?> repository;
8687

8788
private Sort sort;
8889

@@ -132,7 +133,7 @@ public void setPageSize(int pageSize) {
132133
* implementation used to read input from.
133134
* @param repository underlying repository for input to be read from.
134135
*/
135-
public void setRepository(PagingAndSortingRepository<?, ?> repository) {
136+
public void setRepository(PagingAndSortingRepository<T, ?> repository) {
136137
this.repository = repository;
137138
}
138139

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/builder/RepositoryItemReaderBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444
public class RepositoryItemReaderBuilder<T> {
4545

46-
private PagingAndSortingRepository<?, ?> repository;
46+
private PagingAndSortingRepository<T, ?> repository;
4747

4848
private Map<String, Sort.Direction> sorts;
4949

@@ -165,7 +165,7 @@ public RepositoryItemReaderBuilder<T> pageSize(int pageSize) {
165165
* @return The current instance of the builder.
166166
* @see RepositoryItemReader#setRepository(PagingAndSortingRepository)
167167
*/
168-
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<?, ?> repository) {
168+
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<T, ?> repository) {
169169
this.repository = repository;
170170

171171
return this;

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/RepositoryItemReaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 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.
@@ -343,7 +343,7 @@ public void testResetOfPage() throws Exception {
343343
assertEquals("3", reader.read());
344344
}
345345

346-
public interface TestRepository extends PagingAndSortingRepository<Map, Long> {
346+
public interface TestRepository extends PagingAndSortingRepository<String, Long> {
347347

348348
Page<String> findFirstNames(Pageable pageable);
349349

0 commit comments

Comments
 (0)