I'm using the Jooq generator, and for each DAO I want to have a simple generic interface that each DAO extends for basic crud functions.
Something like CrudDao<ItrNeGroup>
where ItrNeGroup
is the POJO name for the table (it extends NamedEntity
)
How do I determine the class name for the POJO based on the Definition passed to the getJavaClassImplements
method, and how do I create a type reference that will be understood?
My current method is (second if statement is the relevant one):
override fun getJavaClassImplements(definition: Definition, mode: GeneratorStrategy.Mode): List<String> {
LOGGER.info("Class Implements: Generator mode is $mode for ${definition.qualifiedName}")
if (mode == GeneratorStrategy.Mode.POJO && definition.name?.startsWith("itr_ne_") == true) {
return listOf(NamedEntity::class.java.name)
}
if(mode == GeneratorStrategy.Mode.POJO && definition.name?.startsWith("itr_ne_") == true) {
val tr = object: TypeReference<CrudDao<WHAT_IS_THE_POJO_CLASS>>
return listOf(tr)
}
return emptyList()
}
Just return "CrudDao<" + getJavaClassName(definition, Mode.POJO) + ">"
to get the strategy's POJO class name for the table. You can assume it's already imported because it's referenced from elsewhere. Otherwise, just call getFullJavaClassName(definition, Mode.POJO)