[#5703] Add option to disable code generation of comments

This commit is contained in:
lukaseder 2018-01-09 15:38:47 +01:00
parent 1c23e0f96b
commit 06f14b1f91
7 changed files with 951 additions and 39 deletions

View File

@ -94,6 +94,20 @@ abstract class AbstractGenerator implements Generator {
boolean generateGlobalQueueReferences = true;
boolean generateGlobalLinkReferences = true;
boolean generateGlobalKeyReferences = true;
boolean generateComments = true;
boolean generateCommentsOnAttributes = true;
boolean generateCommentsOnCatalogs = true;
boolean generateCommentsOnColumns = true;
boolean generateCommentsOnKeys = true;
boolean generateCommentsOnLinks = true;
boolean generateCommentsOnPackages = true;
boolean generateCommentsOnParameters = true;
boolean generateCommentsOnQueues = true;
boolean generateCommentsOnRoutines = true;
boolean generateCommentsOnSchemas = true;
boolean generateCommentsOnSequences = true;
boolean generateCommentsOnTables = true;
boolean generateCommentsOnUDTs = true;
boolean generateFluentSetters = false;
boolean generateJavaBeansGettersAndSetters = false;
boolean generateVarargsSetters = true;
@ -556,6 +570,146 @@ abstract class AbstractGenerator implements Generator {
this.generateKeys = keys;
}
@Override
public boolean generateComments() {
return generateComments;
}
@Override
public void setGenerateComments(boolean comments) {
this.generateComments = comments;
}
@Override
public boolean generateCommentsOnAttributes() {
return generateComments() && generateCommentsOnAttributes;
}
@Override
public void setGenerateCommentsOnAttributes(boolean commentsOnAttributes) {
this.generateCommentsOnAttributes = commentsOnAttributes;
}
@Override
public boolean generateCommentsOnCatalogs() {
return generateComments() && generateCommentsOnCatalogs;
}
@Override
public void setGenerateCommentsOnCatalogs(boolean commentsOnCatalogs) {
this.generateCommentsOnCatalogs = commentsOnCatalogs;
}
@Override
public boolean generateCommentsOnColumns() {
return generateComments() && generateCommentsOnColumns;
}
@Override
public void setGenerateCommentsOnColumns(boolean commentsOnColumns) {
this.generateCommentsOnColumns = commentsOnColumns;
}
@Override
public boolean generateCommentsOnKeys() {
return generateComments() && generateCommentsOnKeys;
}
@Override
public void setGenerateCommentsOnKeys(boolean commentsOnKeys) {
this.generateCommentsOnKeys = commentsOnKeys;
}
@Override
public boolean generateCommentsOnLinks() {
return generateComments() && generateCommentsOnLinks;
}
@Override
public void setGenerateCommentsOnLinks(boolean commentsOnLinks) {
this.generateCommentsOnLinks = commentsOnLinks;
}
@Override
public boolean generateCommentsOnPackages() {
return generateComments() && generateCommentsOnPackages;
}
@Override
public void setGenerateCommentsOnPackages(boolean commentsOnPackages) {
this.generateCommentsOnPackages = commentsOnPackages;
}
@Override
public boolean generateCommentsOnParameters() {
return generateComments() && generateCommentsOnParameters;
}
@Override
public void setGenerateCommentsOnParameters(boolean commentsOnParameters) {
this.generateCommentsOnParameters = commentsOnParameters;
}
@Override
public boolean generateCommentsOnQueues() {
return generateComments() && generateCommentsOnQueues;
}
@Override
public void setGenerateCommentsOnQueues(boolean commentsOnQueues) {
this.generateCommentsOnQueues = commentsOnQueues;
}
@Override
public boolean generateCommentsOnRoutines() {
return generateComments() && generateCommentsOnRoutines;
}
@Override
public void setGenerateCommentsOnRoutines(boolean commentsOnRoutines) {
this.generateCommentsOnRoutines = commentsOnRoutines;
}
@Override
public boolean generateCommentsOnSchemas() {
return generateComments() && generateCommentsOnSchemas;
}
@Override
public void setGenerateCommentsOnSchemas(boolean commentsOnSchemas) {
this.generateCommentsOnSchemas = commentsOnSchemas;
}
@Override
public boolean generateCommentsOnSequences() {
return generateComments() && generateCommentsOnSequences;
}
@Override
public void setGenerateCommentsOnSequences(boolean commentsOnSequences) {
this.generateCommentsOnSequences = commentsOnSequences;
}
@Override
public boolean generateCommentsOnTables() {
return generateComments() && generateCommentsOnTables;
}
@Override
public void setGenerateCommentsOnTables(boolean commentsOnTables) {
this.generateCommentsOnTables = commentsOnTables;
}
@Override
public boolean generateCommentsOnUDTs() {
return generateComments() && generateCommentsOnUDTs;
}
@Override
public void setGenerateCommentsOnUDTs(boolean commentsOnUDTs) {
this.generateCommentsOnUDTs = commentsOnUDTs;
}
@Override
@Deprecated
public boolean fluentSetters() {

View File

@ -642,6 +642,34 @@ public class GenerationTool {
generator.setGenerateGlobalLinkReferences(g.getGenerate().isGlobalLinkReferences());
if (g.getGenerate().isGlobalKeyReferences() != null)
generator.setGenerateGlobalKeyReferences(g.getGenerate().isGlobalKeyReferences());
if (g.getGenerate().isComments() != null)
generator.setGenerateComments(g.getGenerate().isComments());
if (g.getGenerate().isCommentsOnAttributes() != null)
generator.setGenerateCommentsOnAttributes(g.getGenerate().isCommentsOnAttributes());
if (g.getGenerate().isCommentsOnCatalogs() != null)
generator.setGenerateCommentsOnCatalogs(g.getGenerate().isCommentsOnCatalogs());
if (g.getGenerate().isCommentsOnColumns() != null)
generator.setGenerateCommentsOnColumns(g.getGenerate().isCommentsOnColumns());
if (g.getGenerate().isCommentsOnKeys() != null)
generator.setGenerateCommentsOnKeys(g.getGenerate().isCommentsOnKeys());
if (g.getGenerate().isCommentsOnLinks() != null)
generator.setGenerateCommentsOnLinks(g.getGenerate().isCommentsOnLinks());
if (g.getGenerate().isCommentsOnPackages() != null)
generator.setGenerateCommentsOnPackages(g.getGenerate().isCommentsOnPackages());
if (g.getGenerate().isCommentsOnParameters() != null)
generator.setGenerateCommentsOnParameters(g.getGenerate().isCommentsOnParameters());
if (g.getGenerate().isCommentsOnQueues() != null)
generator.setGenerateCommentsOnQueues(g.getGenerate().isCommentsOnQueues());
if (g.getGenerate().isCommentsOnRoutines() != null)
generator.setGenerateCommentsOnRoutines(g.getGenerate().isCommentsOnRoutines());
if (g.getGenerate().isCommentsOnSchemas() != null)
generator.setGenerateCommentsOnSchemas(g.getGenerate().isCommentsOnSchemas());
if (g.getGenerate().isCommentsOnSequences() != null)
generator.setGenerateCommentsOnSequences(g.getGenerate().isCommentsOnSequences());
if (g.getGenerate().isCommentsOnTables() != null)
generator.setGenerateCommentsOnTables(g.getGenerate().isCommentsOnTables());
if (g.getGenerate().isCommentsOnUDTs() != null)
generator.setGenerateCommentsOnUDTs(g.getGenerate().isCommentsOnUDTs());
if (g.getGenerate().isFluentSetters() != null)
generator.setGenerateFluentSetters(g.getGenerate().isFluentSetters());
if (g.getGenerate().isJavaBeansGettersAndSetters() != null)

View File

@ -393,6 +393,146 @@ public interface Generator {
*/
void setGenerateGlobalKeyReferences(boolean globalKeyReferences);
/**
* Whether any SQL comments should be generated as Javadoc.
*/
boolean generateComments();
/**
* Whether any SQL comments should be generated as Javadoc.
*/
void setGenerateComments(boolean comments);
/**
* Whether SQL comments on attributes should be generated as Javadoc.
*/
boolean generateCommentsOnAttributes();
/**
* Whether SQL comments on attributes should be generated as Javadoc.
*/
void setGenerateCommentsOnAttributes(boolean commentsOnAttributes);
/**
* Whether SQL comments on catalogs should be generated as Javadoc.
*/
boolean generateCommentsOnCatalogs();
/**
* Whether SQL comments on catalogs should be generated as Javadoc.
*/
void setGenerateCommentsOnCatalogs(boolean commentsOnCatalogs);
/**
* Whether SQL comments on columns should be generated as Javadoc.
*/
boolean generateCommentsOnColumns();
/**
* Whether SQL comments on columns should be generated as Javadoc.
*/
void setGenerateCommentsOnColumns(boolean commentsOnColumns);
/**
* Whether SQL comments on keys should be generated as Javadoc.
*/
boolean generateCommentsOnKeys();
/**
* Whether SQL comments on keys should be generated as Javadoc.
*/
void setGenerateCommentsOnKeys(boolean commentsOnKeys);
/**
* Whether SQL comments on links should be generated as Javadoc.
*/
boolean generateCommentsOnLinks();
/**
* Whether SQL comments on links should be generated as Javadoc.
*/
void setGenerateCommentsOnLinks(boolean commentsOnLinks);
/**
* Whether SQL comments on packages should be generated as Javadoc.
*/
boolean generateCommentsOnPackages();
/**
* Whether SQL comments on packages should be generated as Javadoc.
*/
void setGenerateCommentsOnPackages(boolean commentsOnPackages);
/**
* Whether SQL comments on parameters should be generated as Javadoc.
*/
boolean generateCommentsOnParameters();
/**
* Whether SQL comments on parameters should be generated as Javadoc.
*/
void setGenerateCommentsOnParameters(boolean commentsOnParameters);
/**
* Whether SQL comments on queues should be generated as Javadoc.
*/
boolean generateCommentsOnQueues();
/**
* Whether SQL comments on queues should be generated as Javadoc.
*/
void setGenerateCommentsOnQueues(boolean commentsOnQueues);
/**
* Whether SQL comments on routines should be generated as Javadoc.
*/
boolean generateCommentsOnRoutines();
/**
* Whether SQL comments on routines should be generated as Javadoc.
*/
void setGenerateCommentsOnRoutines(boolean commentsOnRoutines);
/**
* Whether SQL comments on schemas should be generated as Javadoc.
*/
boolean generateCommentsOnSchemas();
/**
* Whether SQL comments on schemas should be generated as Javadoc.
*/
void setGenerateCommentsOnSchemas(boolean commentsOnSchemas);
/**
* Whether SQL comments on sequences should be generated as Javadoc.
*/
boolean generateCommentsOnSequences();
/**
* Whether SQL comments on sequences should be generated as Javadoc.
*/
void setGenerateCommentsOnSequences(boolean commentsOnSequences);
/**
* Whether SQL comments on tables should be generated as Javadoc.
*/
boolean generateCommentsOnTables();
/**
* Whether SQL comments on tables should be generated as Javadoc.
*/
void setGenerateCommentsOnTables(boolean commentsOnTables);
/**
* Whether SQL comments on UDTs should be generated as Javadoc.
*/
boolean generateCommentsOnUDTs();
/**
* Whether SQL comments on UDTs should be generated as Javadoc.
*/
void setGenerateCommentsOnUDTs(boolean commentsOnUDTs);
/**
* Whether queue related code should be generated
*/

View File

@ -278,6 +278,20 @@ public class JavaGenerator extends AbstractGenerator {
log.info(" annotations (JPA: any)", generateJPAAnnotations());
log.info(" annotations (JPA: version)", generateJPAVersion());
log.info(" annotations (validation)", generateValidationAnnotations());
log.info(" comments", generateComments());
log.info(" comments on attributes", generateCommentsOnAttributes());
log.info(" comments on catalogs", generateCommentsOnCatalogs());
log.info(" comments on columns", generateCommentsOnColumns());
log.info(" comments on keys", generateCommentsOnKeys());
log.info(" comments on links", generateCommentsOnLinks());
log.info(" comments on packages", generateCommentsOnPackages());
log.info(" comments on parameters", generateCommentsOnParameters());
log.info(" comments on queues", generateCommentsOnQueues());
log.info(" comments on routines", generateCommentsOnRoutines());
log.info(" comments on schemas", generateCommentsOnSchemas());
log.info(" comments on sequences", generateCommentsOnSequences());
log.info(" comments on tables", generateCommentsOnTables());
log.info(" comments on udts", generateCommentsOnUDTs());
log.info(" daos", generateDaos());
log.info(" deprecated code", generateDeprecated());
log.info(" global references (any)", generateGlobalObjectReferences());
@ -1489,7 +1503,7 @@ public class JavaGenerator extends AbstractGenerator {
// We cannot have covariant setters for arrays because of type erasure
if (!(generateInterfaces() && isArray)) {
if (!printDeprecationIfUnknownType(out, typeFull))
out.tab(1).javadoc("Setter for <code>%s</code>.%s", name, defaultIfBlank(" " + escapeEntities(comment), ""));
out.tab(1).javadoc("Setter for <code>%s</code>.%s", name, columnComment(column, comment));
if (scala) {
out.tab(1).println("def %s(value : %s) : %s = {", setter, type, setterReturnType);
@ -1590,7 +1604,7 @@ public class JavaGenerator extends AbstractGenerator {
final String name = column.getQualifiedOutputName();
if (!printDeprecationIfUnknownType(out, typeFull))
out.tab(1).javadoc("Getter for <code>%s</code>.%s", name, defaultIfBlank(" " + escapeEntities(comment), ""));
out.tab(1).javadoc("Getter for <code>%s</code>.%s", name, columnComment(column, comment));
if (column.getContainer() instanceof TableDefinition)
printColumnJPAAnnotation(out, (ColumnDefinition) column);
@ -1636,7 +1650,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateRecordClassJavadoc(TableDefinition table, JavaWriter out) {
printClassJavadoc(out, table);
if (generateCommentsOnTables())
printClassJavadoc(out, table);
else
printClassJavadoc(out, "The table <code>" + table.getQualifiedInputName() + "</code>.");
}
private String refRowType(JavaWriter out, Collection<? extends TypedElementDefinition<?>> columns) {
@ -1779,7 +1796,7 @@ public class JavaGenerator extends AbstractGenerator {
final String name = column.getQualifiedOutputName();
if (!printDeprecationIfUnknownType(out, typeFull))
out.tab(1).javadoc("Setter for <code>%s</code>.%s", name, defaultIfBlank(" " + escapeEntities(comment), ""));
out.tab(1).javadoc("Setter for <code>%s</code>.%s", name, columnComment(column, comment));
if (scala)
out.tab(1).println("def %s(value : %s) : %s", setter, type, setterReturnType);
@ -1809,7 +1826,7 @@ public class JavaGenerator extends AbstractGenerator {
final String name = column.getQualifiedOutputName();
if (!printDeprecationIfUnknownType(out, typeFull))
out.tab(1).javadoc("Getter for <code>%s</code>.%s", name, defaultIfBlank(" " + escapeEntities(comment), ""));
out.tab(1).javadoc("Getter for <code>%s</code>.%s", name, columnComment(column, comment));
if (column instanceof ColumnDefinition)
printColumnJPAAnnotation(out, (ColumnDefinition) column);
@ -1822,6 +1839,19 @@ public class JavaGenerator extends AbstractGenerator {
out.tab(1).println("public %s %s();", type, getter);
}
private String columnComment(TypedElementDefinition<?> column, String comment) {
return column instanceof ColumnDefinition && generateCommentsOnColumns()
|| column instanceof AttributeDefinition && generateCommentsOnAttributes()
? defaultIfBlank(" " + escapeEntities(comment), "")
: "";
}
private String parameterComment(String comment) {
return generateCommentsOnParameters()
? defaultIfBlank(" " + escapeEntities(comment), "")
: "";
}
/**
* Subclasses may override this method to provide interface class footer
* code.
@ -1833,7 +1863,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateInterfaceClassJavadoc(TableDefinition table, JavaWriter out) {
printClassJavadoc(out, table);
if (generateCommentsOnTables())
printClassJavadoc(out, table);
else
printClassJavadoc(out, "The table <code>" + table.getQualifiedInputName() + "</code>.");
}
protected void generateUDTs(SchemaDefinition schema) {
@ -1879,7 +1912,7 @@ public class JavaGenerator extends AbstractGenerator {
final String attrId = out.ref(getStrategy().getJavaIdentifier(attribute), 2);
final String attrComment = StringUtils.defaultString(attribute.getComment());
out.tab(1).javadoc("The attribute <code>%s</code>.%s", attribute.getQualifiedOutputName(), defaultIfBlank(" " + escapeEntities(attrComment), ""));
out.tab(1).javadoc("The attribute <code>%s</code>.%s", attribute.getQualifiedOutputName(), columnComment(attribute, attrComment));
out.tab(1).println("val %s = %s.%s", attrId, udtId, attrId);
}
@ -1923,7 +1956,7 @@ public class JavaGenerator extends AbstractGenerator {
}
else {
if (!printDeprecationIfUnknownType(out, attrTypeFull))
out.tab(1).javadoc("The attribute <code>%s</code>.%s", attribute.getQualifiedOutputName(), defaultIfBlank(" " + attrComment, ""));
out.tab(1).javadoc("The attribute <code>%s</code>.%s", attribute.getQualifiedOutputName(), columnComment(attribute, attrComment));
out.tab(1).println("public static final %s<%s, %s> %s = createField(\"%s\", %s, %s, \"%s\"" + converterTemplate(converter) + converterTemplate(binding) + ");",
UDTField.class, recordType, attrType, attrId, attrName, attrTypeRef, udtId, escapeString(""), converter, binding);
@ -1990,7 +2023,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateUDTClassJavadoc(UDTDefinition udt, JavaWriter out) {
printClassJavadoc(out, udt);
if (generateCommentsOnUDTs())
printClassJavadoc(out, udt);
else
printClassJavadoc(out, "The udt <code>" + udt.getQualifiedInputName() + "</code>.");
}
protected void generateUDTPojos(SchemaDefinition schema) {
@ -2018,7 +2054,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateUDTPojoClassJavadoc(UDTDefinition udt, JavaWriter out) {
printClassJavadoc(out, udt);
if (generateCommentsOnUDTs())
printClassJavadoc(out, udt);
else
printClassJavadoc(out, "The udt <code>" + udt.getQualifiedInputName() + "</code>.");
}
protected void generateUDTInterfaces(SchemaDefinition schema) {
@ -2045,7 +2084,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateUDTInterfaceClassJavadoc(UDTDefinition udt, JavaWriter out) {
printClassJavadoc(out, udt);
if (generateCommentsOnUDTs())
printClassJavadoc(out, udt);
else
printClassJavadoc(out, "The udt <code>" + udt.getQualifiedInputName() + "</code>.");
}
/**
@ -2075,7 +2117,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateUDTRecordClassJavadoc(UDTDefinition udt, JavaWriter out) {
printClassJavadoc(out, udt);
if (generateCommentsOnUDTs())
printClassJavadoc(out, udt);
else
printClassJavadoc(out, "The udt <code>" + udt.getQualifiedInputName() + "</code>.");
}
protected void generateUDTRoutines(SchemaDefinition schema) {
@ -2267,7 +2312,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateArrayClassJavadoc(ArrayDefinition array, JavaWriter out) {
printClassJavadoc(out, array);
if (generateCommentsOnUDTs())
printClassJavadoc(out, array);
else
printClassJavadoc(out, "The type <code>" + array.getQualifiedInputName() + "</code>.");
}
protected void generateEnums(SchemaDefinition schema) {
@ -2447,7 +2495,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateEnumClassJavadoc(EnumDefinition e, JavaWriter out) {
printClassJavadoc(out, e);
if (generateCommentsOnUDTs())
printClassJavadoc(out, e);
else
printClassJavadoc(out, "The enum <code>" + e.getQualifiedInputName() + "</code>.");
}
protected void generateDomain(DomainDefinition d) {
@ -2489,7 +2540,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateDomainClassJavadoc(DomainDefinition e, JavaWriter out) {
printClassJavadoc(out, e);
if (generateCommentsOnUDTs())
printClassJavadoc(out, e);
else
printClassJavadoc(out, "The domain <code>" + e.getQualifiedInputName() + "</code>.");
}
protected void generateRoutines(SchemaDefinition schema) {
@ -2700,7 +2754,7 @@ public class JavaGenerator extends AbstractGenerator {
final String className = out.ref(getStrategy().getFullJavaClassName(table));
final String id = getStrategy().getJavaIdentifier(table);
final String fullId = getStrategy().getFullJavaIdentifier(table);
final String comment = !StringUtils.isBlank(table.getComment())
final String comment = !StringUtils.isBlank(table.getComment()) && generateCommentsOnTables()
? escapeEntities(table.getComment())
: "The table <code>" + table.getQualifiedOutputName() + "</code>.";
@ -2938,7 +2992,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateDaoClassJavadoc(TableDefinition table, JavaWriter out) {
printClassJavadoc(out, table);
if (generateCommentsOnTables())
printClassJavadoc(out, table);
else
printClassJavadoc(out, "The table <code>" + table.getQualifiedInputName() + "</code>.");
}
protected void generatePojos(SchemaDefinition schema) {
@ -3514,7 +3571,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generatePojoClassJavadoc(TableDefinition table, JavaWriter out) {
printClassJavadoc(out, table);
if (generateCommentsOnTables())
printClassJavadoc(out, table);
else
printClassJavadoc(out, "The table <code>" + table.getQualifiedInputName() + "</code>.");
}
protected void generateTables(SchemaDefinition schema) {
@ -3595,7 +3655,7 @@ public class JavaGenerator extends AbstractGenerator {
final List<String> binding = out.ref(list(column.getType(resolver()).getBinding()));
if (!printDeprecationIfUnknownType(out, columnTypeFull))
out.tab(1).javadoc("The column <code>%s</code>.%s", column.getQualifiedOutputName(), defaultIfBlank(" " + escapeEntities(columnComment), ""));
out.tab(1).javadoc("The column <code>%s</code>.%s", column.getQualifiedOutputName(), columnComment(column, columnComment));
if (scala) {
out.tab(1).println("val %s : %s[%s, %s] = createField(\"%s\", %s, \"%s\"" + converterTemplate(converter) + converterTemplate(binding) + ")",
@ -4085,7 +4145,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateTableClassJavadoc(TableDefinition table, JavaWriter out) {
printClassJavadoc(out, table);
if (generateCommentsOnTables())
printClassJavadoc(out, table);
else
printClassJavadoc(out, "The table <code>" + table.getQualifiedInputName() + "</code>.");
}
protected void generateSequences(SchemaDefinition schema) {
@ -4171,7 +4234,7 @@ public class JavaGenerator extends AbstractGenerator {
final String schemaClassName = out.ref(getStrategy().getFullJavaClassName(schema));
final String schemaId = getStrategy().getJavaIdentifier(schema);
final String schemaFullId = getStrategy().getFullJavaIdentifier(schema);
final String schemaComment = !StringUtils.isBlank(schema.getComment())
final String schemaComment = !StringUtils.isBlank(schema.getComment()) && generateCommentsOnSchemas()
? escapeEntities(schema.getComment())
: "The schema <code>" + schema.getQualifiedOutputName() + "</code>.";
@ -4209,8 +4272,11 @@ public class JavaGenerator extends AbstractGenerator {
/**
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateCatalogClassJavadoc(CatalogDefinition schema, JavaWriter out) {
printClassJavadoc(out, schema);
protected void generateCatalogClassJavadoc(CatalogDefinition catalog, JavaWriter out) {
if (generateCommentsOnCatalogs())
printClassJavadoc(out, catalog);
else
printClassJavadoc(out, "The catalog <code>" + catalog.getQualifiedInputName() + "</code>.");
}
protected void generateSchema(SchemaDefinition schema) {
@ -4255,7 +4321,7 @@ public class JavaGenerator extends AbstractGenerator {
final String tableClassName = out.ref(getStrategy().getFullJavaClassName(table));
final String tableId = getStrategy().getJavaIdentifier(table);
final String tableFullId = getStrategy().getFullJavaIdentifier(table);
final String tableComment = !StringUtils.isBlank(table.getComment())
final String tableComment = !StringUtils.isBlank(table.getComment()) && generateCommentsOnTables()
? escapeEntities(table.getComment())
: "The table <code>" + table.getQualifiedOutputName() + "</code>.";
@ -4314,7 +4380,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateSchemaClassJavadoc(SchemaDefinition schema, JavaWriter out) {
printClassJavadoc(out, schema);
if (generateCommentsOnSchemas())
printClassJavadoc(out, schema);
else
printClassJavadoc(out, "The schema <code>" + schema.getQualifiedInputName() + "</code>.");
}
protected void printFromAndInto(JavaWriter out, TableDefinition table) {
@ -4666,7 +4735,7 @@ public class JavaGenerator extends AbstractGenerator {
));
if (!printDeprecationIfUnknownType(out, paramTypeFull))
out.tab(1).javadoc("The parameter <code>%s</code>.%s", parameter.getQualifiedOutputName(), defaultIfBlank(" " + escapeEntities(paramComment), ""));
out.tab(1).javadoc("The parameter <code>%s</code>.%s", parameter.getQualifiedOutputName(), parameterComment(paramComment));
out.tab(1).println("val %s : %s[%s] = %s.createParameter(\"%s\", %s, %s, %s[[before=, ][new %s]])",
paramId, Parameter.class, paramType, AbstractRoutine.class, paramName, paramTypeRef, isDefaulted, isUnnamed, converters);
@ -4703,7 +4772,7 @@ public class JavaGenerator extends AbstractGenerator {
final List<String> binding = out.ref(list(parameter.getType(resolver()).getBinding()));
if (!printDeprecationIfUnknownType(out, paramTypeFull))
out.tab(1).javadoc("The parameter <code>%s</code>.%s", parameter.getQualifiedOutputName(), defaultIfBlank(" " + paramComment, ""));
out.tab(1).javadoc("The parameter <code>%s</code>.%s", parameter.getQualifiedOutputName(), parameterComment(paramComment));
out.tab(1).println("public static final %s<%s> %s = createParameter(\"%s\", %s, %s, %s" + converterTemplate(converter) + converterTemplate(binding) + ");",
Parameter.class, paramType, paramId, paramName, paramTypeRef, isDefaulted, isUnnamed, converter, binding);
@ -4867,7 +4936,10 @@ public class JavaGenerator extends AbstractGenerator {
* Subclasses may override this method to provide their own Javadoc.
*/
protected void generateRoutineClassJavadoc(RoutineDefinition routine, JavaWriter out) {
printClassJavadoc(out, routine);
if (generateCommentsOnRoutines())
printClassJavadoc(out, routine);
else
printClassJavadoc(out, "The routine <code>" + routine.getQualifiedInputName() + "</code>.");
}
protected void printConvenienceMethodFunctionAsField(JavaWriter out, RoutineDefinition function, boolean parametersAsField) {

View File

@ -106,7 +106,9 @@ public class XMLGenerator extends AbstractGenerator {
String catalogName = c.getOutputName();
if (hasNonDefaultCatalogs)
is.getCatalogs().add(new Catalog().withCatalogName(catalogName).withComment(c.getComment()));
is.getCatalogs().add(new Catalog()
.withCatalogName(catalogName)
.withComment(generateCommentsOnCatalogs() ? c.getComment() : null));
for (SchemaDefinition s : c.getSchemata()) {
String schemaName = s.getOutputName();
@ -114,7 +116,9 @@ public class XMLGenerator extends AbstractGenerator {
Schema schema = new Schema();
schema.setCatalogName(catalogName);
schema.setSchemaName(schemaName);
schema.setComment(s.getComment());
if (generateCommentsOnSchemas())
schema.setComment(s.getComment());
is.getSchemata().add(schema);
@ -125,7 +129,9 @@ public class XMLGenerator extends AbstractGenerator {
table.setTableCatalog(catalogName);
table.setTableSchema(schemaName);
table.setTableName(tableName);
table.setComment(t.getComment());
if (generateCommentsOnTables())
table.setComment(t.getComment());
is.getTables().add(table);
@ -138,7 +144,10 @@ public class XMLGenerator extends AbstractGenerator {
column.setTableSchema(schemaName);
column.setTableName(tableName);
column.setColumnName(columnName);
column.setComment(co.getComment());
if (generateCommentsOnColumns())
column.setComment(co.getComment());
column.setCharacterMaximumLength(type.getLength());
column.setColumnDefault(type.getDefaultValue());
column.setDataType(type.getType());
@ -162,7 +171,10 @@ public class XMLGenerator extends AbstractGenerator {
index.setIndexCatalog(catalogName);
index.setIndexSchema(schemaName);
index.setIndexName(indexName);
index.setComment(i.getComment());
if (generateCommentsOnKeys())
index.setComment(i.getComment());
index.setTableCatalog(table.getCatalog().getOutputName());
index.setTableSchema(table.getSchema().getOutputName());
index.setTableName(table.getOutputName());
@ -199,7 +211,10 @@ public class XMLGenerator extends AbstractGenerator {
constraint.setConstraintSchema(schemaName);
constraint.setConstraintName(constraintName);
constraint.setConstraintType(u.isPrimaryKey() ? PRIMARY_KEY : UNIQUE);
constraint.setComment(u.getComment());
if (generateCommentsOnKeys())
constraint.setComment(u.getComment());
constraint.setTableCatalog(table.getCatalog().getOutputName());
constraint.setTableSchema(table.getSchema().getOutputName());
constraint.setTableName(table.getOutputName());
@ -235,7 +250,10 @@ public class XMLGenerator extends AbstractGenerator {
tc.setConstraintSchema(schemaName);
tc.setConstraintName(constraintName);
tc.setConstraintType(FOREIGN_KEY);
tc.setComment(f.getComment());
if (generateCommentsOnKeys())
tc.setComment(f.getComment());
tc.setTableCatalog(table.getCatalog().getOutputName());
tc.setTableSchema(table.getSchema().getOutputName());
tc.setTableName(table.getOutputName());
@ -278,7 +296,10 @@ public class XMLGenerator extends AbstractGenerator {
constraint.setConstraintSchema(schemaName);
constraint.setConstraintName(constraintName);
constraint.setConstraintType(CHECK);
constraint.setComment(ch.getComment());
if (generateCommentsOnKeys())
constraint.setComment(ch.getComment());
constraint.setTableCatalog(table.getCatalog().getOutputName());
constraint.setTableSchema(table.getSchema().getOutputName());
constraint.setTableName(table.getOutputName());
@ -294,7 +315,10 @@ public class XMLGenerator extends AbstractGenerator {
sequence.setSequenceCatalog(catalogName);
sequence.setSequenceSchema(schemaName);
sequence.setSequenceName(sequenceName);
sequence.setComment(se.getComment());
if (generateCommentsOnSequences())
sequence.setComment(se.getComment());
sequence.setCharacterMaximumLength(type.getLength());
sequence.setDataType(type.getType());
sequence.setNumericPrecision(type.getPrecision());
@ -334,7 +358,9 @@ public class XMLGenerator extends AbstractGenerator {
routine.setRoutineName(r.getName());
routine.setSpecificName(specificName);
routine.setComment(r.getComment());
if (generateCommentsOnRoutines())
routine.setComment(r.getComment());
if (r.getReturnValue() == null) {
routine.setRoutineType(RoutineType.PROCEDURE);
@ -363,7 +389,9 @@ public class XMLGenerator extends AbstractGenerator {
parameter.setSpecificName(specificName);
parameter.setOrdinalPosition(i++);
parameter.setParameterName(p.getName());
parameter.setComment(p.getComment());
if (generateCommentsOnParameters())
parameter.setComment(p.getComment());
boolean in = r.getInParameters().contains(p);
boolean out = r.getOutParameters().contains(p);

View File

@ -106,6 +106,34 @@ public class Generate implements Serializable
protected Boolean globalLinkReferences = true;
@XmlElement(defaultValue = "true")
protected Boolean globalKeyReferences = true;
@XmlElement(defaultValue = "true")
protected Boolean comments = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnCatalogs = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnSchemas = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnTables = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnColumns = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnUDTs = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnAttributes = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnPackages = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnRoutines = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnParameters = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnSequences = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnLinks = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnQueues = true;
@XmlElement(defaultValue = "true")
protected Boolean commentsOnKeys = true;
@XmlElement(defaultValue = "false")
protected Boolean fluentSetters = false;
@XmlElement(defaultValue = "false")
@ -992,6 +1020,342 @@ public class Generate implements Serializable
this.globalKeyReferences = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all objects.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isComments() {
return comments;
}
/**
* Sets the value of the comments property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setComments(Boolean value) {
this.comments = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all catalogs.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnCatalogs() {
return commentsOnCatalogs;
}
/**
* Sets the value of the commentsOnCatalogs property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnCatalogs(Boolean value) {
this.commentsOnCatalogs = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all schemas.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnSchemas() {
return commentsOnSchemas;
}
/**
* Sets the value of the commentsOnSchemas property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnSchemas(Boolean value) {
this.commentsOnSchemas = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all tables.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnTables() {
return commentsOnTables;
}
/**
* Sets the value of the commentsOnTables property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnTables(Boolean value) {
this.commentsOnTables = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all columns.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnColumns() {
return commentsOnColumns;
}
/**
* Sets the value of the commentsOnColumns property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnColumns(Boolean value) {
this.commentsOnColumns = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all UDTs.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnUDTs() {
return commentsOnUDTs;
}
/**
* Sets the value of the commentsOnUDTs property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnUDTs(Boolean value) {
this.commentsOnUDTs = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all attributes.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnAttributes() {
return commentsOnAttributes;
}
/**
* Sets the value of the commentsOnAttributes property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnAttributes(Boolean value) {
this.commentsOnAttributes = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all packages.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnPackages() {
return commentsOnPackages;
}
/**
* Sets the value of the commentsOnPackages property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnPackages(Boolean value) {
this.commentsOnPackages = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all routines.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnRoutines() {
return commentsOnRoutines;
}
/**
* Sets the value of the commentsOnRoutines property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnRoutines(Boolean value) {
this.commentsOnRoutines = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all parameters.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnParameters() {
return commentsOnParameters;
}
/**
* Sets the value of the commentsOnParameters property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnParameters(Boolean value) {
this.commentsOnParameters = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all sequences.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnSequences() {
return commentsOnSequences;
}
/**
* Sets the value of the commentsOnSequences property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnSequences(Boolean value) {
this.commentsOnSequences = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all links.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnLinks() {
return commentsOnLinks;
}
/**
* Sets the value of the commentsOnLinks property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnLinks(Boolean value) {
this.commentsOnLinks = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all queues.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnQueues() {
return commentsOnQueues;
}
/**
* Sets the value of the commentsOnQueues property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnQueues(Boolean value) {
this.commentsOnQueues = value;
}
/**
* Turn off generation of all SQL comments as Javadoc on all keys.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isCommentsOnKeys() {
return commentsOnKeys;
}
/**
* Sets the value of the commentsOnKeys property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setCommentsOnKeys(Boolean value) {
this.commentsOnKeys = value;
}
/**
* Generate fluent setters in records, POJOs, interfaces.
*
@ -1390,6 +1754,76 @@ public class Generate implements Serializable
return this;
}
public Generate withComments(Boolean value) {
setComments(value);
return this;
}
public Generate withCommentsOnCatalogs(Boolean value) {
setCommentsOnCatalogs(value);
return this;
}
public Generate withCommentsOnSchemas(Boolean value) {
setCommentsOnSchemas(value);
return this;
}
public Generate withCommentsOnTables(Boolean value) {
setCommentsOnTables(value);
return this;
}
public Generate withCommentsOnColumns(Boolean value) {
setCommentsOnColumns(value);
return this;
}
public Generate withCommentsOnUDTs(Boolean value) {
setCommentsOnUDTs(value);
return this;
}
public Generate withCommentsOnAttributes(Boolean value) {
setCommentsOnAttributes(value);
return this;
}
public Generate withCommentsOnPackages(Boolean value) {
setCommentsOnPackages(value);
return this;
}
public Generate withCommentsOnRoutines(Boolean value) {
setCommentsOnRoutines(value);
return this;
}
public Generate withCommentsOnParameters(Boolean value) {
setCommentsOnParameters(value);
return this;
}
public Generate withCommentsOnSequences(Boolean value) {
setCommentsOnSequences(value);
return this;
}
public Generate withCommentsOnLinks(Boolean value) {
setCommentsOnLinks(value);
return this;
}
public Generate withCommentsOnQueues(Boolean value) {
setCommentsOnQueues(value);
return this;
}
public Generate withCommentsOnKeys(Boolean value) {
setCommentsOnKeys(value);
return this;
}
public Generate withFluentSetters(Boolean value) {
setFluentSetters(value);
return this;

View File

@ -968,6 +968,62 @@ jOOQ version used for source code]]></jxb:javadoc></jxb:property></appinfo></ann
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of global key references.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="comments" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all objects.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnCatalogs" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all catalogs.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnSchemas" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all schemas.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnTables" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all tables.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnColumns" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all columns.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnUDTs" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all UDTs.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnAttributes" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all attributes.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnPackages" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all packages.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnRoutines" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all routines.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnParameters" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all parameters.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnSequences" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all sequences.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnLinks" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all links.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnQueues" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all queues.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="commentsOnKeys" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Turn off generation of all SQL comments as Javadoc on all keys.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="fluentSetters" type="boolean" default="false" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate fluent setters in records, POJOs, interfaces.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>