Package de.cuioss.test.generator.impl
Class ZoneOffsetGenerator
java.lang.Object
de.cuioss.test.generator.impl.ZoneOffsetGenerator
- All Implemented Interfaces:
TypedGenerator<ZoneOffset>
Generates
ZoneOffset instances based on the available system time zones.
This generator creates offsets by sampling from all available zone IDs and
extracting their current offsets.
Features:
- Uses all system-available zone IDs (
ZoneId.getAvailableZoneIds()) - Generates valid offsets based on current time
- Covers both positive and negative offsets
- Thread-safe implementation
Example usage:
// Create a generator
var generator = new ZoneOffsetGenerator();
// Generate single values
ZoneOffset offset = generator.next();
// Generate collections
var collectionGen = new CollectionGenerator<>(generator);
List<ZoneOffset> offsets = collectionGen.list(5); // List of 5 offsets
This generator is particularly useful for testing:
- Time zone offset calculations
- UTC conversions
- Date-time formatting with offsets
- International time handling
- Author:
- Eugen Fischer
- See Also:
-
Constructor Details
-
ZoneOffsetGenerator
public ZoneOffsetGenerator()
-
-
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<ZoneOffset>- 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<ZoneOffset>- Returns:
- The class information indicating which type this generator is responsible for.
-