All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spock.genesis.generators.TransformingGenerator.groovy Maven / Gradle / Ivy

Go to download

Mostly lazy data generators for property based testing using the Spock test framework

The newest version!
package spock.genesis.generators

import groovy.transform.CompileStatic

@CompileStatic
class TransformingGenerator extends GeneratorDecorator {
    private final Closure transform

    TransformingGenerator(Generator iterable, Closure transform) {
        super(iterable)
        this.transform = transform
    }

    UnmodifiableIterator iterator() {
        final Iterator ITERATOR = super.iterator()
        new UnmodifiableIterator() {
            @Override
            boolean hasNext() {
                ITERATOR.hasNext()
            }

            T next() {
                transform.call(ITERATOR.next())
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy