[#6072] Add code generation flag to configure whether generated Records should implement Record[N]
This commit is contained in:
parent
28c179b45f
commit
80f59e17ad
@ -66,6 +66,7 @@ abstract class AbstractGenerator implements Generator {
|
||||
boolean generateUDTs = true;
|
||||
boolean generateTables = true;
|
||||
boolean generateRecords = true;
|
||||
boolean generateRecordsImplementingRecordN = true;
|
||||
boolean generatePojos = false;
|
||||
boolean generatePojosEqualsAndHashCode = false;
|
||||
boolean generatePojosToString = true;
|
||||
@ -315,6 +316,16 @@ abstract class AbstractGenerator implements Generator {
|
||||
this.generateRecords = generateRecords;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateRecordsImplementingRecordN() {
|
||||
return generateRecords() && generateRecordsImplementingRecordN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerateRecordsImplementingRecordN(boolean generateRecordsImplementingRecordN) {
|
||||
this.generateRecordsImplementingRecordN = generateRecordsImplementingRecordN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generatePojos() {
|
||||
|
||||
|
||||
@ -540,6 +540,8 @@ public class GenerationTool {
|
||||
generator.setGenerateTables(g.getGenerate().isTables());
|
||||
if (g.getGenerate().isRecords() != null)
|
||||
generator.setGenerateRecords(g.getGenerate().isRecords());
|
||||
if (g.getGenerate().isRecordsImplementingRecordN() != null)
|
||||
generator.setGenerateRecordsImplementingRecordN(g.getGenerate().isRecordsImplementingRecordN());
|
||||
if (g.getGenerate().isPojos() != null)
|
||||
generator.setGeneratePojos(g.getGenerate().isPojos());
|
||||
if (g.getGenerate().isImmutablePojos() != null)
|
||||
|
||||
@ -184,6 +184,16 @@ public interface Generator {
|
||||
*/
|
||||
void setGenerateRecords(boolean generateRecords);
|
||||
|
||||
/**
|
||||
* Whether TableRecords should be generated in addition to tables, which implement Record[N] types
|
||||
*/
|
||||
boolean generateRecordsImplementingRecordN();
|
||||
|
||||
/**
|
||||
* Whether TableRecords should be generated in addition to tables, which implement Record[N] types
|
||||
*/
|
||||
void setGenerateRecordsImplementingRecordN(boolean generateRecordsImplementingRecordN);
|
||||
|
||||
/**
|
||||
* Whether POJO's should be generated in addition to records
|
||||
*/
|
||||
|
||||
@ -1123,7 +1123,8 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
String rowTypeRecord = null;
|
||||
|
||||
// [#3130] Invalid UDTs may have a degree of 0
|
||||
if (degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
|
||||
// [#6072] Generate these super types only if configured to do so
|
||||
if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
|
||||
rowType = refRowType(out, columns);
|
||||
|
||||
if (scala)
|
||||
@ -1208,7 +1209,7 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
}
|
||||
|
||||
// [#3130] Invalid UDTs may have a degree of 0
|
||||
if (degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
|
||||
if (generateRecordsImplementingRecordN() && degree > 0 && degree <= Constants.MAX_ROW_DEGREE) {
|
||||
out.tab(1).header("Record%s type implementation", degree);
|
||||
|
||||
// fieldsRow()
|
||||
|
||||
@ -60,6 +60,8 @@ public class Generate implements Serializable
|
||||
protected Boolean tables = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean records = true;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean recordsImplementingRecordN = true;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean pojos = false;
|
||||
@XmlElement(defaultValue = "false")
|
||||
@ -430,6 +432,30 @@ public class Generate implements Serializable
|
||||
this.records = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate TableRecord classes that implement Record[N] super types
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isRecordsImplementingRecordN() {
|
||||
return recordsImplementingRecordN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the recordsImplementingRecordN property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setRecordsImplementingRecordN(Boolean value) {
|
||||
this.recordsImplementingRecordN = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate POJOs.
|
||||
*
|
||||
@ -1145,6 +1171,11 @@ public class Generate implements Serializable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withRecordsImplementingRecordN(Boolean value) {
|
||||
setRecordsImplementingRecordN(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withPojos(Boolean value) {
|
||||
setPojos(value);
|
||||
return this;
|
||||
|
||||
@ -876,6 +876,10 @@ jOOQ version used for source code]]></jxb:javadoc></jxb:property></appinfo></ann
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate TableRecord classes.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="recordsImplementingRecordN" type="boolean" default="true" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate TableRecord classes that implement Record[N] super types]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="pojos" type="boolean" default="false" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate POJOs.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user