Class AbstractORMCreator

java.lang.Object
mocka.orm.generator.AbstractORMCreator
All Implemented Interfaces:
Creator
Direct Known Subclasses:
HibernateCreator, MyBatisCreator

public abstract class AbstractORMCreator extends Object implements Creator
  • Constructor Details

    • AbstractORMCreator

      public AbstractORMCreator()
  • Method Details

    • handleValueSource

      public <T> T handleValueSource(Field field)
      Handles field value generation for fields annotated with ValueSource.

      This method resolves a generator from the GeneratorRegistry using the information provided in the ValueSource annotation. It follows a priority-based resolution strategy:

      1. Generator Key: If generatorKey is specified, looks up the generator directly by key
      2. Path and Type: If both path and type are specified, looks up the generator using path and type information

      Usage Examples:

       // Using generator key
       @ValueSource(generatorKey = "name")
       private String name;
      
       // Using path and type
       @ValueSource(path = "user.email", type = String.class)
       private String email;
       
      Specified by:
      handleValueSource in interface Creator
      Type Parameters:
      T - the expected return type of the generated value
      Parameters:
      field - the field annotated with ValueSource
      Returns:
      the generated value from the resolved generator
      Throws:
      ValueSourceException - if the generator cannot be resolved from the ValueSource annotation (e.g., when neither generatorKey nor path+type combination is properly specified)
    • handleRegexSource

      public String handleRegexSource(Field field)
      Specified by:
      handleRegexSource in interface Creator
    • initInstance

      public <T> T initInstance(Class<T> clazz)
      Specified by:
      initInstance in interface Creator