Package de.cuioss.test.generator.impl
Class LocalDateGenerator
java.lang.Object
de.cuioss.test.generator.impl.LocalDateGenerator
- All Implemented Interfaces:
TypedGenerator<LocalDate>
Generates
LocalDate instances within a reasonable range around the epoch.
The generator creates dates between approximately 63 years before and after the epoch
(1970-01-01), providing a good range for most testing scenarios.
Features:
- Generates dates from -23000 to +23000 days from epoch
- Covers dates from roughly 1907 to 2033
- Even distribution across the range
- Thread-safe implementation
Example usage:
// Create a generator
var generator = new LocalDateGenerator();
// Generate single values
LocalDate date = generator.next();
// Generate collections
var collectionGen = new CollectionGenerator<>(generator);
List<LocalDate> dates = collectionGen.list(5); // List of 5 dates
This generator is particularly useful for testing:
- Date formatting and parsing
- Date calculations and comparisons
- Business logic involving dates
- Author:
- Eugen Fischer
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LocalDateGenerator
public LocalDateGenerator()
-
-
Method Details
-
next
Description copied from interface:TypedGeneratorGenerates the next instance based on the generator's configuration. Implementations must ensure thread-safety.- Specified by:
nextin interfaceTypedGenerator<LocalDate>- Returns:
- A newly created instance. May be null if the generator explicitly supports null value generation.
-
getType
Description copied from interface:TypedGeneratorProvides type information about what kind of objects this generator creates. The default implementation uses the first non-null result fromTypedGenerator.next()to determine the type.Note: If your generator may return null values or the generated type differs from the actual instance type, you should override this method.
- Specified by:
getTypein interfaceTypedGenerator<LocalDate>- Returns:
- The class information indicating which type this generator is responsible for.
-