Class FloatObjectGenerator

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

public class FloatObjectGenerator extends Object implements TypedGenerator<Float>
Generates Float objects within a configurable range.

Features:

  • Configurable range through constructor parameters
  • Default range: Float.MIN_VALUE to Float.MAX_VALUE
  • Thread-safe implementation
  • Uses double precision for internal generation to ensure even distribution

Example usage:

 // Generate floats using full range
 var generator = new FloatObjectGenerator();
 Float value = generator.next();
 
 // Generate floats within specific range
 var rangeGenerator = new FloatObjectGenerator(0.0f, 100.0f);
 Float bounded = rangeGenerator.next(); // Value between 0 and 100
 
Author:
Oliver Wolff
See Also:
  • Constructor Details

  • Method Details

    • next

      public Float 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<Float>
      Returns:
      A newly created instance. May be null if the generator explicitly supports null value generation.
    • getType

      public Class<Float> 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<Float>
      Returns:
      The class information indicating which type this generator is responsible for.