Class MyBatisFieldValueGenerator

java.lang.Object
mocka.generator.orm.mybatis.MyBatisFieldValueGenerator
All Implemented Interfaces:
FieldValueGenerator

@Component public class MyBatisFieldValueGenerator extends Object implements FieldValueGenerator
Implementation of FieldValueGenerator specialized for MyBatis.

This component is responsible for generating random or mock values for fields of entities managed by MyBatis. It supports:

  • Primitive and wrapper types (int, long, float, double, boolean, char, etc.)
  • Enum types
  • BigDecimal, BigInteger
  • Date/time classes from java.util, java.time, and java.sql
  • Primitive arrays (byte[], char[])

If the given field type is unsupported, an UnsupportedOperationException will be thrown.

  • Constructor Details

    • MyBatisFieldValueGenerator

      public MyBatisFieldValueGenerator()
  • Method Details

    • get

      public Object get(Field field)
      Generates a random value for the given field based on its type and annotations.
      Specified by:
      get in interface FieldValueGenerator
      Parameters:
      field - the field to generate a value for
      Returns:
      a randomly generated value appropriate for the field type, or null if the field should not be generated
      Throws:
      RuntimeException - if @Email is used on a non-String field
      UnsupportedOperationException - if the field type is not supported