class LimitDataGenerator extends DataGenerator<A> {

    @Override
    public DataGenerator<A> apply() {
        if (remaining == 0) {
            return (DataGenerator<A>) EOS;
        }
        DataGenerator nextGen = source.apply();
        if (nextGen.isClosed()) {
            return (DataGenerator<A>) EOS;
        }
        return new LimitDataGenerator<>(nextGen, remaining);
    }

    private  LimitDataGenerator(DataGenerator<A> source, int count);

}