Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Subclasses in the CompositeItemReader #4682

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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