![JAR search and dependency download from the Maven repository](/logo.png)
net.jqwik.time.api.arbitraries.LocalDateArbitrary Maven / Gradle / Ivy
package net.jqwik.time.api.arbitraries;
import java.time.*;
import org.apiguardian.api.*;
import net.jqwik.api.*;
import static org.apiguardian.api.API.Status.*;
/**
* Fluent interface to configure the generation of local date values.
* All generated dates use the Gregorian Calendar, even if they are before October 15, 1582.
* By default, local dates with years between 1900 and 2500 are generated.
*/
@API(status = EXPERIMENTAL, since = "1.4.0")
public interface LocalDateArbitrary extends Arbitrary {
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated local date values.
*/
default LocalDateArbitrary between(LocalDate min, LocalDate max) {
if (min.isAfter(max)) {
return atTheEarliest(max).atTheLatest(min);
}
return atTheEarliest(min).atTheLatest(max);
}
/**
* Set the allowed lower {@code min} (included) bounder of generated local date values.
*/
LocalDateArbitrary atTheEarliest(LocalDate min);
/**
* Set the allowed upper {@code max} (included) bounder of generated local date values.
*/
LocalDateArbitrary atTheLatest(LocalDate max);
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated year values.
* The years can be between {@code 1} and {@code Year.MAX_VALUE}.
*
* Calling this method is equivalent to calling {@linkplain #between(LocalDate, LocalDate)}
* assuming Jan 1 and Dec 31 as first and last day of those years.
*/
LocalDateArbitrary yearBetween(Year min, Year max);
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated year values.
* The {@code int} values can be between {@code 1} and {@code Year.MAX_VALUE}.
*
* Calling this method is equivalent to calling {@linkplain #between(LocalDate, LocalDate)}
* assuming Jan 1 and Dec 31 as first and last day of those years.
*/
default LocalDateArbitrary yearBetween(int min, int max) {
return yearBetween(Year.of(min), Year.of(max));
}
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated month values.
*/
LocalDateArbitrary monthBetween(Month min, Month max);
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated month values.
* The {@code int} values can be between 1 and 12.
*/
default LocalDateArbitrary monthBetween(int min, int max) {
return monthBetween(Month.of(min), Month.of(max));
}
/**
* Set an array of allowed {@code months}.
*/
LocalDateArbitrary onlyMonths(Month... months);
/**
* Set the allowed lower {@code min} (included) and upper {@code max} (included) bounder of generated day of month values.
* The {@code int} values can be between 1 and 31.
*/
LocalDateArbitrary dayOfMonthBetween(int min, int max);
/**
* Set an array of allowed {@code daysOfWeek}.
*/
LocalDateArbitrary onlyDaysOfWeek(DayOfWeek... daysOfWeek);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy