Provide generator abstraction
Closed this issue · 1 comments
jangalinski commented
Currently implementers of a generator have to come up with a combination of input criterias, context factories and strategy selection.
Simplify usage by providing generate-function that does all this in one stop.
jangalinski commented
inline fun <INPUT:Any, CONTEXT: KotlinCodeGenerationContext<CONTEXT>, reified STRATEGY: KotlinFileSpecStrategy<CONTEXT, INPUT>> generateFn(
input: INPUT,
contextFactory: (INPUT) -> CONTEXT,
) : List<KotlinFileSpec> {
val context = contextFactory.invoke(input)
return context.registry.strategies.filter(STRATEGY::class).executeAll(context, input)
}