Skip to content

SequenceWriter.writeAll() could accept Iterable #924

@jkremser

Description

@jkremser

Currently the method from ${subject} looks like this:

public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException {
        for (Object value : container) {
            write(value);
        }
        return this;
    }

The only assumption on the container is therefore it can be iterated through it using the for each loop. That being said, the signature can be weaken to accept also the ? extends Iterable. Could you please change it to

public <I extends Iterable<?>> SequenceWriter writeAll(I iterable) throws IOException {
        for (Object value : iterable) {
            write(value);
        }
        return this;
    }

Collection extends Iterable, hence no API-breakage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions