class FilterDataGenerator extends DataGenerator<A> {

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

    private  FilterDataGenerator(DataGenerator<A> source, Function<A, Boolean> predicate);

}