How can I change the Table class names using the by extending jOOQ's DefaultGeneratorStrategy?

400 Views Asked by At

I am using the jooq codgen gradle plugin to change the naming convention for generated tables to include Table at the end of the class name. However, I am not sure how to distinguish a table from a schema in the generator.

My naming override is:

@Override
public String getJavaClassName(Definition definition, Mode mode) {
    String result = super.getJavaClassName(definition, mode);
    if (mode == Mode.DEFAULT) {
        result += "Table";
    }
    return result;
}

Is there a way to determine If the current object extends TableImpl or maybe I need to take a different approach?

1

There are 1 best solutions below

1
On BEST ANSWER

Just use instanceof checks on your definition, like this:

@Override
public String getJavaClassName(Definition definition, Mode mode) {
    String result = super.getJavaClassName(definition, mode);
    if (mode == Mode.DEFAULT && definition instanceof TableDefinition) {
        result += "Table";
    }
    return result;
}