Class ShortObjectGenerator

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

public class ShortObjectGenerator extends Object implements TypedGenerator<Short>
Generates Short objects across the full range of possible short values.

Features:

  • Generates values from -32,768 to 32,767 (Short.MIN_VALUE to Short.MAX_VALUE)
  • Even distribution across the entire short range
  • Thread-safe implementation
  • Uses integer generation internally for precision

Example usage:

 var generator = new ShortObjectGenerator();
 Short value = generator.next(); // Returns a random short value
 

This generator is particularly useful for testing:

  • Boundary conditions at Short.MIN_VALUE and Short.MAX_VALUE
  • Type conversion scenarios
  • Numeric overflow cases
Author:
Oliver Wolff
See Also:
  • Constructor Details

  • Method Details

    • next

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

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