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

spock.genesis.generators.values.DateGenerator.groovy Maven / Gradle / Ivy

package spock.genesis.generators.values

import groovy.transform.CompileStatic
import spock.genesis.generators.InfiniteGenerator
import spock.genesis.generators.InfiniteIterator

@CompileStatic
class DateGenerator extends InfiniteGenerator {

    final LongGenerator millisProvider

    DateGenerator() {
        this.millisProvider = new LongGenerator()
    }

    DateGenerator(Date minDate, Date maxDate) {
        this.millisProvider = new LongGenerator(minDate.time, maxDate.time)
    }

    InfiniteIterator iterator() {
        final Iterator TIME = millisProvider.iterator()
        new InfiniteIterator() {
            @Override
            Date next() {
                new Date(TIME.next())
            }
        }
    }

    @Override
    DateGenerator seed(Long seed) {
        super.seed(seed)
        millisProvider.seed(seed)
        this
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy