[jOOQ/jOOQ#10090] Add a <generatedAnnotationDate/> flag to allow for turning off generating @Generated.date()
This commit is contained in:
parent
833cd9c62d
commit
6b0ea7fe4e
@ -68,6 +68,7 @@ abstract class AbstractGenerator implements Generator {
|
||||
boolean generateInstanceFields = true;
|
||||
boolean generateGeneratedAnnotation = false;
|
||||
GeneratedAnnotationType generatedGeneratedAnnotationType = GeneratedAnnotationType.DETECT_FROM_JDK;
|
||||
boolean generateGeneratedAnnotationDate = true;
|
||||
boolean generateNonnullAnnotation = false;
|
||||
String generatedNonnullAnnotationType = "javax.annotation.Nonnull";
|
||||
boolean generateNullableAnnotation = false;
|
||||
@ -307,6 +308,16 @@ abstract class AbstractGenerator implements Generator {
|
||||
this.generatedGeneratedAnnotationType = generateGeneratedAnnotationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateGeneratedAnnotationDate() {
|
||||
return generateGeneratedAnnotationDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerateGeneratedAnnotationDate(boolean generateGeneratedAnnotationDate) {
|
||||
this.generateGeneratedAnnotationDate = generateGeneratedAnnotationDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateNonnullAnnotation() {
|
||||
return generateNonnullAnnotation;
|
||||
|
||||
@ -670,6 +670,8 @@ public class GenerationTool {
|
||||
generator.setGenerateGeneratedAnnotation(g.getGenerate().isGeneratedAnnotation());
|
||||
if (g.getGenerate().getGeneratedAnnotationType() != null)
|
||||
generator.setGenerateGeneratedAnnotationType(g.getGenerate().getGeneratedAnnotationType());
|
||||
if (g.getGenerate().isGeneratedAnnotationDate() != null)
|
||||
generator.setGenerateGeneratedAnnotationDate(g.getGenerate().isGeneratedAnnotationDate());
|
||||
if (g.getGenerate().isNonnullAnnotation() != null)
|
||||
generator.setGenerateNonnullAnnotation(g.getGenerate().isNonnullAnnotation());
|
||||
if (g.getGenerate().getNonnullAnnotationType() != null)
|
||||
|
||||
@ -128,35 +128,58 @@ public interface Generator {
|
||||
void setGenerateTableValuedFunctions(boolean generateTableValuedFunctions);
|
||||
|
||||
/**
|
||||
* Whether instance fields should be generated (as opposed to static fields)
|
||||
* Whether instance fields should be generated (as opposed to static fields).
|
||||
*/
|
||||
boolean generateInstanceFields();
|
||||
|
||||
/**
|
||||
* Whether instance fields should be generated (as opposed to static fields)
|
||||
* Whether instance fields should be generated (as opposed to static
|
||||
* fields).
|
||||
*/
|
||||
void setGenerateInstanceFields(boolean generateInstanceFields);
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should be generated
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should be
|
||||
* generated.
|
||||
*/
|
||||
boolean generateGeneratedAnnotation();
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should be generated
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should be
|
||||
* generated.
|
||||
*/
|
||||
void setGenerateGeneratedAnnotation(boolean generateGeneratedAnnotation);
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should be generated
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should be
|
||||
* generated.
|
||||
*/
|
||||
GeneratedAnnotationType generateGeneratedAnnotationType();
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should be generated
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should be
|
||||
* generated.
|
||||
*/
|
||||
void setGenerateGeneratedAnnotationType(GeneratedAnnotationType generateGeneratedAnnotationType);
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should include
|
||||
* the <code>date</code> attribute.
|
||||
*/
|
||||
boolean generateGeneratedAnnotationDate();
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or
|
||||
* {@link javax.annotation.processing.Generated} annotation should include
|
||||
* the <code>date</code> attribute.
|
||||
*/
|
||||
void setGenerateGeneratedAnnotationDate(boolean generateGeneratedAnnotationDate);
|
||||
|
||||
/**
|
||||
* Whether Nonnull annotations should be generated.
|
||||
* <p>
|
||||
|
||||
@ -6252,7 +6252,8 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
else
|
||||
out.tab(1).println("},");
|
||||
|
||||
out.tab(1).println("date = \"" + isoDate + "\",");
|
||||
if (generateGeneratedAnnotationDate())
|
||||
out.tab(1).println("date = \"" + isoDate + "\",");
|
||||
out.tab(1).println("comments = \"This class is generated by jOOQ\"");
|
||||
}
|
||||
else {
|
||||
|
||||
@ -50,6 +50,8 @@ public class Generate implements Serializable, XMLAppendable
|
||||
@XmlSchemaType(name = "string")
|
||||
protected GeneratedAnnotationType generatedAnnotationType = GeneratedAnnotationType.DETECT_FROM_JDK;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean generatedAnnotationDate = false;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean nonnullAnnotation = false;
|
||||
@XmlElement(defaultValue = "javax.annotation.Nonnull")
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
@ -404,6 +406,30 @@ public class Generate implements Serializable, XMLAppendable
|
||||
this.generatedAnnotationType = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should include the <code>date</code> attribute.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isGeneratedAnnotationDate() {
|
||||
return generatedAnnotationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the generatedAnnotationDate property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setGeneratedAnnotationDate(Boolean value) {
|
||||
this.generatedAnnotationDate = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether non-nullable items should be annotated with the annotation type specified in {@link #nonnullAnnotationType}. In SQL and by consequence in jOOQ, non-nullability cannot be guaranteed statically. There may still be some cases (e.g. after unions, outer joins, etc.) where a normally non-null value turns out to be null!
|
||||
*
|
||||
@ -2068,6 +2094,11 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withGeneratedAnnotationDate(Boolean value) {
|
||||
setGeneratedAnnotationDate(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withNonnullAnnotation(Boolean value) {
|
||||
setNonnullAnnotation(value);
|
||||
return this;
|
||||
@ -2447,6 +2478,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
builder.append("instanceFields", instanceFields);
|
||||
builder.append("generatedAnnotation", generatedAnnotation);
|
||||
builder.append("generatedAnnotationType", generatedAnnotationType);
|
||||
builder.append("generatedAnnotationDate", generatedAnnotationDate);
|
||||
builder.append("nonnullAnnotation", nonnullAnnotation);
|
||||
builder.append("nonnullAnnotationType", nonnullAnnotationType);
|
||||
builder.append("nullableAnnotation", nullableAnnotation);
|
||||
@ -2617,6 +2649,15 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (generatedAnnotationDate == null) {
|
||||
if (other.generatedAnnotationDate!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!generatedAnnotationDate.equals(other.generatedAnnotationDate)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (nonnullAnnotation == null) {
|
||||
if (other.nonnullAnnotation!= null) {
|
||||
return false;
|
||||
@ -3245,6 +3286,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((instanceFields == null)? 0 :instanceFields.hashCode()));
|
||||
result = ((prime*result)+((generatedAnnotation == null)? 0 :generatedAnnotation.hashCode()));
|
||||
result = ((prime*result)+((generatedAnnotationType == null)? 0 :generatedAnnotationType.hashCode()));
|
||||
result = ((prime*result)+((generatedAnnotationDate == null)? 0 :generatedAnnotationDate.hashCode()));
|
||||
result = ((prime*result)+((nonnullAnnotation == null)? 0 :nonnullAnnotation.hashCode()));
|
||||
result = ((prime*result)+((nonnullAnnotationType == null)? 0 :nonnullAnnotationType.hashCode()));
|
||||
result = ((prime*result)+((nullableAnnotation == null)? 0 :nullableAnnotation.hashCode()));
|
||||
|
||||
@ -1139,6 +1139,10 @@ jOOQ version used for source code.]]></jxb:javadoc></jxb:property></appinfo></an
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation to indicate
|
||||
jOOQ version used for source code.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="generatedAnnotationDate" type="boolean" default="false" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether the {@link javax.annotation.Generated} or {@link javax.annotation.processing.Generated} annotation should include the <code>date</code> attribute.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="nonnullAnnotation" type="boolean" default="false" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Whether non-nullable items should be annotated with the annotation type specified in {@link #nonnullAnnotationType}. In SQL and by consequence in jOOQ, non-nullability cannot be guaranteed statically. There may still be some cases (e.g. after unions, outer joins, etc.) where a normally non-null value turns out to be null!]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user