[jOOQ/jOOQ#8353] Support placing comments on embeddables
This commit is contained in:
parent
0abfdbec0c
commit
fe96278656
@ -800,6 +800,8 @@ public class GenerationTool {
|
||||
generator.setGenerateCommentsOnSequences(g.getGenerate().isCommentsOnSequences());
|
||||
if (g.getGenerate().isCommentsOnTables() != null)
|
||||
generator.setGenerateCommentsOnTables(g.getGenerate().isCommentsOnTables());
|
||||
if (g.getGenerate().isCommentsOnEmbeddables() != null)
|
||||
generator.setGenerateCommentsOnEmbeddables(g.getGenerate().isCommentsOnEmbeddables());
|
||||
if (g.getGenerate().isCommentsOnUDTs() != null)
|
||||
generator.setGenerateCommentsOnUDTs(g.getGenerate().isCommentsOnUDTs());
|
||||
if (g.getGenerate().isSources() != null)
|
||||
|
||||
@ -4791,7 +4791,7 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
for (EmbeddableColumnDefinition column : embeddable.getColumns())
|
||||
columnIds.add(out.ref(getStrategy().getJavaIdentifier(column.getReferencingColumn()), colRefSegments(column.getReferencingColumn())));
|
||||
|
||||
out.javadoc("The embeddable type <code>%s</code>.", embeddable.getOutputName());
|
||||
out.javadoc("The embeddable type <code>%s</code>.[[before= ][%s]]", embeddable.getOutputName(), list(escapeEntities(referencingComment(embeddable))));
|
||||
|
||||
if (scala)
|
||||
out.println("val %s: %s[%s, %s] = %s.createEmbeddable(%s.name(\"%s\"), classOf[%s], %s, this, [[%s]])",
|
||||
@ -7319,6 +7319,7 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
|| definition instanceof SchemaDefinition && generateCommentsOnSchemas()
|
||||
|| definition instanceof TableDefinition && generateCommentsOnTables()
|
||||
|| definition instanceof ColumnDefinition && generateCommentsOnColumns()
|
||||
|| definition instanceof EmbeddableDefinition && generateCommentsOnEmbeddables()
|
||||
|| definition instanceof UDTDefinition && generateCommentsOnUDTs()
|
||||
|| definition instanceof AttributeDefinition && generateCommentsOnAttributes()
|
||||
|| definition instanceof PackageDefinition && generateCommentsOnPackages()
|
||||
@ -7329,6 +7330,12 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
: "";
|
||||
}
|
||||
|
||||
private String referencingComment(EmbeddableDefinition definition) {
|
||||
return generateCommentsOnEmbeddables()
|
||||
? StringUtils.defaultIfBlank(definition.getReferencingComment(), "")
|
||||
: "";
|
||||
}
|
||||
|
||||
protected void printClassJavadoc(JavaWriter out, String comment) {
|
||||
if (generateJavadoc()) {
|
||||
out.println("/**");
|
||||
|
||||
@ -1975,9 +1975,11 @@ public abstract class AbstractDatabase implements Database {
|
||||
new DefaultEmbeddableDefinition(
|
||||
schema,
|
||||
embeddable.getName(),
|
||||
embeddable.getComment(),
|
||||
table,
|
||||
names,
|
||||
defaultIfBlank(embeddable.getReferencingName(), embeddable.getName()),
|
||||
defaultIfBlank(embeddable.getReferencingComment(), embeddable.getComment()),
|
||||
table,
|
||||
columns,
|
||||
TRUE.equals(embeddable.isReplacesFields())
|
||||
@ -2086,6 +2088,11 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ public class DefaultEmbeddableDefinition
|
||||
private final TableDefinition definingTable;
|
||||
private final List<String> definingColumnNames;
|
||||
private final String referencingName;
|
||||
private final String referencingComment;
|
||||
private final TableDefinition referencingTable;
|
||||
private final List<EmbeddableColumnDefinition> embeddableColumns;
|
||||
private final boolean replacesFields;
|
||||
@ -62,18 +63,21 @@ public class DefaultEmbeddableDefinition
|
||||
public DefaultEmbeddableDefinition(
|
||||
SchemaDefinition definingSchema,
|
||||
String definingName,
|
||||
String definingComment,
|
||||
TableDefinition definingTable,
|
||||
List<String> definingColumnNames,
|
||||
String referencingName,
|
||||
String referencingComment,
|
||||
TableDefinition referencingTable,
|
||||
List<ColumnDefinition> referencingColumns,
|
||||
boolean replacesFields
|
||||
) {
|
||||
super(definingSchema, definingName, "");
|
||||
super(definingSchema, definingName, definingComment);
|
||||
|
||||
this.definingColumnNames = definingColumnNames;
|
||||
this.definingTable = definingTable;
|
||||
this.referencingName = referencingName;
|
||||
this.referencingComment = referencingComment;
|
||||
this.referencingTable = referencingTable;
|
||||
this.embeddableColumns = new ArrayList<>();
|
||||
this.replacesFields = replacesFields;
|
||||
@ -97,6 +101,11 @@ public class DefaultEmbeddableDefinition
|
||||
return definingTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getReferencingComment() {
|
||||
return referencingComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getReferencingName() {
|
||||
return getReferencingInputName();
|
||||
|
||||
@ -52,6 +52,12 @@ public interface EmbeddableDefinition extends TableElementDefinition {
|
||||
*/
|
||||
TableDefinition getDefiningTable();
|
||||
|
||||
/**
|
||||
* The referencing comment of this embeddable, if it differs from the
|
||||
* defining name ({@link #getComment()}).
|
||||
*/
|
||||
String getReferencingComment();
|
||||
|
||||
/**
|
||||
* The referencing name of this embeddable, if it differs from the defining
|
||||
* name ({@link #getName()}).
|
||||
@ -59,14 +65,14 @@ public interface EmbeddableDefinition extends TableElementDefinition {
|
||||
String getReferencingName();
|
||||
|
||||
/**
|
||||
* The referencing input name of this embeddable, if it differs from the defining
|
||||
* name ({@link #getInputName()}).
|
||||
* The referencing input name of this embeddable, if it differs from the
|
||||
* defining name ({@link #getInputName()}).
|
||||
*/
|
||||
String getReferencingInputName();
|
||||
|
||||
/**
|
||||
* The referencing output name of this embeddable, if it differs from the defining
|
||||
* name ({@link #getOutputName()}).
|
||||
* The referencing output name of this embeddable, if it differs from the
|
||||
* defining name ({@link #getOutputName()}).
|
||||
*/
|
||||
String getReferencingOutputName();
|
||||
|
||||
|
||||
@ -40,8 +40,12 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String name;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String comment;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String referencingName;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String referencingComment;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
protected String tables;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean replacesFields = false;
|
||||
@ -97,6 +101,22 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The defining comment on the embeddable type.
|
||||
*
|
||||
*/
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The defining comment on the embeddable type.
|
||||
*
|
||||
*/
|
||||
public void setComment(String value) {
|
||||
this.comment = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The referencing name of the embeddable type, defaulting to the defining name.
|
||||
*
|
||||
@ -113,6 +133,22 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
this.referencingName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The referencing comment on the embeddable type, defaulting to the defining comment.
|
||||
*
|
||||
*/
|
||||
public String getReferencingComment() {
|
||||
return referencingComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The referencing comment on the embeddable type, defaulting to the defining comment.
|
||||
*
|
||||
*/
|
||||
public void setReferencingComment(String value) {
|
||||
this.referencingComment = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A regular expression matching the tables to which to apply the embeddable definition.
|
||||
*
|
||||
@ -191,6 +227,15 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The defining comment on the embeddable type.
|
||||
*
|
||||
*/
|
||||
public EmbeddableDefinitionType withComment(String value) {
|
||||
setComment(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The referencing name of the embeddable type, defaulting to the defining name.
|
||||
*
|
||||
@ -200,6 +245,15 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The referencing comment on the embeddable type, defaulting to the defining comment.
|
||||
*
|
||||
*/
|
||||
public EmbeddableDefinitionType withReferencingComment(String value) {
|
||||
setReferencingComment(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A regular expression matching the tables to which to apply the embeddable definition.
|
||||
*
|
||||
@ -240,7 +294,9 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
builder.append("catalog", catalog);
|
||||
builder.append("schema", schema);
|
||||
builder.append("name", name);
|
||||
builder.append("comment", comment);
|
||||
builder.append("referencingName", referencingName);
|
||||
builder.append("referencingComment", referencingComment);
|
||||
builder.append("tables", tables);
|
||||
builder.append("replacesFields", replacesFields);
|
||||
builder.append("fields", "field", fields);
|
||||
@ -292,6 +348,15 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (comment == null) {
|
||||
if (other.comment!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!comment.equals(other.comment)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (referencingName == null) {
|
||||
if (other.referencingName!= null) {
|
||||
return false;
|
||||
@ -301,6 +366,15 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (referencingComment == null) {
|
||||
if (other.referencingComment!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!referencingComment.equals(other.referencingComment)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (tables == null) {
|
||||
if (other.tables!= null) {
|
||||
return false;
|
||||
@ -338,7 +412,9 @@ public class EmbeddableDefinitionType implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((catalog == null)? 0 :catalog.hashCode()));
|
||||
result = ((prime*result)+((schema == null)? 0 :schema.hashCode()));
|
||||
result = ((prime*result)+((name == null)? 0 :name.hashCode()));
|
||||
result = ((prime*result)+((comment == null)? 0 :comment.hashCode()));
|
||||
result = ((prime*result)+((referencingName == null)? 0 :referencingName.hashCode()));
|
||||
result = ((prime*result)+((referencingComment == null)? 0 :referencingComment.hashCode()));
|
||||
result = ((prime*result)+((tables == null)? 0 :tables.hashCode()));
|
||||
result = ((prime*result)+((replacesFields == null)? 0 :replacesFields.hashCode()));
|
||||
result = ((prime*result)+((fields == null)? 0 :fields.hashCode()));
|
||||
|
||||
@ -154,6 +154,8 @@ public class Generate implements Serializable, XMLAppendable
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean commentsOnColumns = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean commentsOnEmbeddables = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean commentsOnUDTs = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean commentsOnAttributes = true;
|
||||
@ -1636,6 +1638,30 @@ public class Generate implements Serializable, XMLAppendable
|
||||
this.commentsOnColumns = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off generation of all SQL comments as Javadoc on all embeddables.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isCommentsOnEmbeddables() {
|
||||
return commentsOnEmbeddables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the commentsOnEmbeddables property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setCommentsOnEmbeddables(Boolean value) {
|
||||
this.commentsOnEmbeddables = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off generation of all SQL comments as Javadoc on all UDTs.
|
||||
*
|
||||
@ -2444,6 +2470,11 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withCommentsOnEmbeddables(Boolean value) {
|
||||
setCommentsOnEmbeddables(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withCommentsOnUDTs(Boolean value) {
|
||||
setCommentsOnUDTs(value);
|
||||
return this;
|
||||
@ -2623,6 +2654,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
builder.append("commentsOnSchemas", commentsOnSchemas);
|
||||
builder.append("commentsOnTables", commentsOnTables);
|
||||
builder.append("commentsOnColumns", commentsOnColumns);
|
||||
builder.append("commentsOnEmbeddables", commentsOnEmbeddables);
|
||||
builder.append("commentsOnUDTs", commentsOnUDTs);
|
||||
builder.append("commentsOnAttributes", commentsOnAttributes);
|
||||
builder.append("commentsOnPackages", commentsOnPackages);
|
||||
@ -3213,6 +3245,15 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (commentsOnEmbeddables == null) {
|
||||
if (other.commentsOnEmbeddables!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!commentsOnEmbeddables.equals(other.commentsOnEmbeddables)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (commentsOnUDTs == null) {
|
||||
if (other.commentsOnUDTs!= null) {
|
||||
return false;
|
||||
@ -3461,6 +3502,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((commentsOnSchemas == null)? 0 :commentsOnSchemas.hashCode()));
|
||||
result = ((prime*result)+((commentsOnTables == null)? 0 :commentsOnTables.hashCode()));
|
||||
result = ((prime*result)+((commentsOnColumns == null)? 0 :commentsOnColumns.hashCode()));
|
||||
result = ((prime*result)+((commentsOnEmbeddables == null)? 0 :commentsOnEmbeddables.hashCode()));
|
||||
result = ((prime*result)+((commentsOnUDTs == null)? 0 :commentsOnUDTs.hashCode()));
|
||||
result = ((prime*result)+((commentsOnAttributes == null)? 0 :commentsOnAttributes.hashCode()));
|
||||
result = ((prime*result)+((commentsOnPackages == null)? 0 :commentsOnPackages.hashCode()));
|
||||
|
||||
@ -1079,10 +1079,18 @@ for Oracle.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The defining name of the embeddable type.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="comment" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The defining comment on the embeddable type.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="referencingName" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The referencing name of the embeddable type, defaulting to the defining name.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="referencingComment" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[The referencing comment on the embeddable type, defaulting to the defining comment.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="tables" type="string" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[A regular expression matching the tables to which to apply the embeddable definition.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
@ -1462,6 +1470,10 @@ jOOQ version used for source code.]]></jxb:javadoc></jxb:property></appinfo></an
|
||||
<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="commentsOnEmbeddables" 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 embeddables.]]></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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user