Package mocka.generator
Class SpringGeneratorFactory
java.lang.Object
mocka.generator.factory.GeneratorRegistry
mocka.generator.factory.GeneratorFactory
mocka.generator.SpringGeneratorFactory
- All Implemented Interfaces:
CommonFactory,ExtendedFactory,PrimitiveFactory,RegexFactory
SpringGeneratorFactory integrates the core GeneratorFactory
with Spring, providing automatic discovery and registration of entity generators
using ORM resolvers.
This factory scans entities from the configured ORMCreator,
registers them, and allows retrieval of EntityGenerator instances
for specific entity classes.
Lifecycle: The initialization process is performed after Spring dependency injection
via the @PostConstruct annotated init() method.
-
Field Summary
Fields inherited from class mocka.generator.factory.GeneratorRegistry
GENERATOR_MAP -
Constructor Summary
ConstructorsConstructorDescriptionSpringGeneratorFactory(EntityInstanceCreator entityInstanceCreator, ORMCreator ormCreator) Constructs a newSpringGeneratorFactorywith the required dependencies. -
Method Summary
Modifier and TypeMethodDescription<T> EntityGenerator<T>getGenerator(Class<T> clazz) Retrieves theEntityGeneratorassociated with the given entity class.Methods inherited from class mocka.generator.factory.GeneratorRegistry
clearAllRegistrableGenerator, clearRegistrableGenerator, existsRegistrableGenerator, getGenerator, getGenerator, getGeneratorNames, putGenerator, putGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface mocka.generator.factory.CommonFactory
asCountry, asDate, asEmail, asLoremIpsum, asName, asNetworkAddress, asPhoneNumberMethods inherited from interface mocka.generator.factory.ExtendedFactory
asBigDecimal, asBigInteger, asByteArray, asCharacterArray, asDateTime, asLegacyDate, asSqlDateMethods inherited from interface mocka.generator.factory.PrimitiveFactory
asBoolean, asByte, asCharacter, asDouble, asFloat, asInteger, asLong, asShort, asStringMethods inherited from interface mocka.generator.factory.RegexFactory
asRegex
-
Constructor Details
-
SpringGeneratorFactory
Constructs a newSpringGeneratorFactorywith the required dependencies.- Parameters:
entityInstanceCreator- the factory responsible for creating entity instancesormCreator- the ORM creator used to provide entity resolvers
-
-
Method Details
-
getGenerator
Retrieves theEntityGeneratorassociated with the given entity class.
When the application starts,SpringGeneratorFactoryautomatically scans and registers all entity generators.Therefore, you do not need to manually register the entity class you want to generate.
- Type Parameters:
T- the entity type- Parameters:
clazz- the entity class- Returns:
- the
EntityGeneratorfor the given class - Throws:
GeneratorException- if no generator is found for the class
-
getEntityGeneratorNames
- Returns:
- list of entity classes with registered generators
-
getOrmCreator
- Returns:
- the ORM creator instance used by this factory.
-