Skip to content

Commit

Permalink
Allow subclasses of items in CompositeItemReader's generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Berse authored and fmbenhassine committed Oct 23, 2024
1 parent c6f5029 commit 7c10a0f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
*/
public class CompositeItemReader<T> implements ItemStreamReader<T> {

private final List<ItemStreamReader<T>> delegates;
private final List<ItemStreamReader<? extends T>> delegates;

private final Iterator<ItemStreamReader<T>> delegatesIterator;
private final Iterator<ItemStreamReader<? extends T>> delegatesIterator;

private ItemStreamReader<T> currentDelegate;
private ItemStreamReader<? extends T> currentDelegate;

/**
* Create a new {@link CompositeItemReader}.
* @param delegates the delegate readers to read data
*/
public CompositeItemReader(List<ItemStreamReader<T>> delegates) {
public CompositeItemReader(List<ItemStreamReader<? extends T>> delegates) {
this.delegates = delegates;
this.delegatesIterator = this.delegates.iterator();
this.currentDelegate = this.delegatesIterator.hasNext() ? this.delegatesIterator.next() : null;
Expand All @@ -52,7 +52,7 @@ public CompositeItemReader(List<ItemStreamReader<T>> delegates) {
// opening resources early for a long time
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
for (ItemStreamReader<T> delegate : delegates) {
for (ItemStreamReader<? extends T> delegate : delegates) {
delegate.open(executionContext);
}
}
Expand All @@ -79,7 +79,7 @@ public void update(ExecutionContext executionContext) throws ItemStreamException

@Override
public void close() throws ItemStreamException {
for (ItemStreamReader<T> delegate : delegates) {
for (ItemStreamReader<? extends T> delegate : delegates) {
delegate.close();
}
}
Expand Down

0 comments on commit 7c10a0f

Please sign in to comment.