Improve generic type handling in RepositoryItemReader

This commit is contained in:
Mahmoud Ben Hassine
2022-07-17 08:18:20 +02:00
parent 5ba363c8ab
commit a30aaac4be
3 changed files with 8 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,13 +76,14 @@ import org.springframework.util.MethodInvoker;
*
* @author Michael Minella
* @author Antoine Kapps
* @author Mahmoud Ben Hassine
* @since 2.2
*/
public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements InitializingBean {
protected Log logger = LogFactory.getLog(getClass());
private PagingAndSortingRepository<?, ?> repository;
private PagingAndSortingRepository<T, ?> repository;
private Sort sort;
@@ -132,7 +133,7 @@ public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemR
* implementation used to read input from.
* @param repository underlying repository for input to be read from.
*/
public void setRepository(PagingAndSortingRepository<?, ?> repository) {
public void setRepository(PagingAndSortingRepository<T, ?> repository) {
this.repository = repository;
}

View File

@@ -43,7 +43,7 @@ import org.springframework.util.StringUtils;
*/
public class RepositoryItemReaderBuilder<T> {
private PagingAndSortingRepository<?, ?> repository;
private PagingAndSortingRepository<T, ?> repository;
private Map<String, Sort.Direction> sorts;
@@ -165,7 +165,7 @@ public class RepositoryItemReaderBuilder<T> {
* @return The current instance of the builder.
* @see RepositoryItemReader#setRepository(PagingAndSortingRepository)
*/
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<?, ?> repository) {
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<T, ?> repository) {
this.repository = repository;
return this;