Class LocalTimeGenerator

java.lang.Object
de.cuioss.test.generator.impl.LocalTimeGenerator
All Implemented Interfaces:
TypedGenerator<LocalTime>

public class LocalTimeGenerator extends Object implements TypedGenerator<LocalTime>
Generates LocalTime instances covering all possible times within a day. The generator creates times with second precision, evenly distributed across the full 24-hour period.

Features:

  • Generates times from 00:00:00 to 23:59:59
  • Uses second-level precision
  • Even distribution across all possible seconds of the day
  • Thread-safe implementation

Example usage:

 
 // Create a generator
 var generator = new LocalTimeGenerator();
 
 // Generate single values
 LocalTime time = generator.next();
 
 // Generate collections
 var collectionGen = new CollectionGenerator&lt;>(generator);
 List&lt;LocalTime&gt; times = collectionGen.list(5); // List of 5 times
 
 

This generator is particularly useful for testing:

  • Time formatting and parsing
  • Time-based calculations
  • Time range validations
  • 24-hour format handling
Author:
Eugen Fischer
See Also:
  • Constructor Details

  • Method Details

    • next

      public LocalTime next()
      Description copied from interface: TypedGenerator
      Generates the next instance based on the generator's configuration. Implementations must ensure thread-safety.
      Specified by:
      next in interface TypedGenerator<LocalTime>
      Returns:
      A newly created instance. May be null if the generator explicitly supports null value generation.
    • getType

      public Class<LocalTime> getType()
      Description copied from interface: TypedGenerator
      Provides type information about what kind of objects this generator creates. The default implementation uses the first non-null result from TypedGenerator.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:
      getType in interface TypedGenerator<LocalTime>
      Returns:
      The class information indicating which type this generator is responsible for.