Class ScaledBigDecimalGenerator

java.lang.Object
io.bloviate.gen.AbstractDataGenerator<BigDecimal>
io.bloviate.gen.ScaledBigDecimalGenerator
All Implemented Interfaces:
DataGenerator<BigDecimal>

public class ScaledBigDecimalGenerator extends AbstractDataGenerator<BigDecimal>
Generates a BigDecimal drawn uniformly from the half-open range [startInclusive, endExclusive) and rounded (HALF_UP) to a fixed scale. Useful for columns that require values within a specific numeric range and decimal scale rather than merely within the column's declared width (e.g. a tax rate constrained to [0.0000, 0.2000]).
  • Method Details

    • generate

      public BigDecimal generate()
      Description copied from interface: DataGenerator
      Generates a random value of type T.
      Returns:
      a generated value, may be null if the generator supports nullable columns
    • set

      public void set(Connection connection, PreparedStatement statement, int parameterIndex, BigDecimal value) throws SQLException
      Description copied from interface: DataGenerator
      Sets a specific value on a PreparedStatement parameter.
      Specified by:
      set in interface DataGenerator<BigDecimal>
      Overrides:
      set in class AbstractDataGenerator<BigDecimal>
      Parameters:
      connection - the database connection
      statement - the prepared statement to set the parameter on
      parameterIndex - the 1-based parameter index
      value - the value to set
      Throws:
      SQLException - if the database operation fails
    • get

      public BigDecimal get(ResultSet resultSet, int columnIndex) throws SQLException
      Description copied from interface: DataGenerator
      Retrieves a value from a ResultSet column.
      Parameters:
      resultSet - the result set to read from
      columnIndex - the 1-based column index
      Returns:
      the value from the result set, properly cast to type T
      Throws:
      SQLException - if the database operation fails