|
@@ -114,6 +114,14 @@ public class Entity implements ITemplate {
|
|
@Getter
|
|
@Getter
|
|
private boolean serialVersionUID = true;
|
|
private boolean serialVersionUID = true;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 是否启用 {@link java.io.Serial} (需JAVA 14) 注解
|
|
|
|
+ *
|
|
|
|
+ * @since 3.5.11
|
|
|
|
+ */
|
|
|
|
+ @Getter
|
|
|
|
+ private boolean serialAnnotation;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 【实体】是否生成字段常量(默认 false)<br>
|
|
* 【实体】是否生成字段常量(默认 false)<br>
|
|
* -----------------------------------<br>
|
|
* -----------------------------------<br>
|
|
@@ -287,14 +295,14 @@ public class Entity implements ITemplate {
|
|
/**
|
|
/**
|
|
* 导包处理方法
|
|
* 导包处理方法
|
|
*
|
|
*
|
|
- * @since 3.5.10.2
|
|
|
|
|
|
+ * @since 3.5.11
|
|
*/
|
|
*/
|
|
private Function<Set<String>, List<String>> importPackageFunction;
|
|
private Function<Set<String>, List<String>> importPackageFunction;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理类注解方法 (含类与字段)
|
|
* 处理类注解方法 (含类与字段)
|
|
*
|
|
*
|
|
- * @since 3.5.10.2
|
|
|
|
|
|
+ * @since 3.5.11
|
|
*/
|
|
*/
|
|
private Function<List<? extends AnnotationAttributes>, List<AnnotationAttributes>> annotationAttributesFunction;
|
|
private Function<List<? extends AnnotationAttributes>, List<AnnotationAttributes>> annotationAttributesFunction;
|
|
|
|
|
|
@@ -412,6 +420,7 @@ public class Entity implements ITemplate {
|
|
data.put("versionFieldName", this.versionColumnName);
|
|
data.put("versionFieldName", this.versionColumnName);
|
|
data.put("activeRecord", this.activeRecord);
|
|
data.put("activeRecord", this.activeRecord);
|
|
data.put("entitySerialVersionUID", this.serialVersionUID);
|
|
data.put("entitySerialVersionUID", this.serialVersionUID);
|
|
|
|
+ data.put("entitySerialAnnotation", this.serialAnnotation);
|
|
data.put("entityColumnConstant", this.columnConstant);
|
|
data.put("entityColumnConstant", this.columnConstant);
|
|
data.put("entityBuilderModel", this.chain);
|
|
data.put("entityBuilderModel", this.chain);
|
|
data.put("chainModel", this.chain);
|
|
data.put("chainModel", this.chain);
|
|
@@ -444,6 +453,12 @@ public class Entity implements ITemplate {
|
|
classAnnotationAttributes.stream().sorted(Comparator.comparingInt(s -> s.getDisplayName().length())).collect(Collectors.toList()));
|
|
classAnnotationAttributes.stream().sorted(Comparator.comparingInt(s -> s.getDisplayName().length())).collect(Collectors.toList()));
|
|
data.put("importEntityPackages", importPackageFunction != null ? importPackageFunction.apply(importPackages) :
|
|
data.put("importEntityPackages", importPackageFunction != null ? importPackageFunction.apply(importPackages) :
|
|
importPackages.stream().sorted().collect(Collectors.toList()));
|
|
importPackages.stream().sorted().collect(Collectors.toList()));
|
|
|
|
+ Set<String> javaPackages = importPackages.stream().filter(pkg -> pkg.startsWith("java")).collect(Collectors.toSet());
|
|
|
|
+ data.put("importEntityJavaPackages", importPackageFunction != null ? importPackageFunction.apply(javaPackages) :
|
|
|
|
+ javaPackages.stream().sorted().collect(Collectors.toList()));
|
|
|
|
+ Set<String> frameworkPackages = importPackages.stream().filter(pkg -> !pkg.startsWith("java")).collect(Collectors.toSet());
|
|
|
|
+ data.put("importEntityFrameworkPackages", importPackageFunction != null ? importPackageFunction.apply(frameworkPackages) :
|
|
|
|
+ frameworkPackages.stream().sorted().collect(Collectors.toList()));
|
|
data.put("entityToString", this.toString);
|
|
data.put("entityToString", this.toString);
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
@@ -500,6 +515,18 @@ public class Entity implements ITemplate {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 启用生成 {@link java.io.Serial} (需JAVA 14)
|
|
|
|
+ * <p>当开启了 {@link #serialVersionUID} 时,会增加 {@link java.io.Serial} 注解在此字段上</p>
|
|
|
|
+ *
|
|
|
|
+ * @return this
|
|
|
|
+ * @since 3.5.11
|
|
|
|
+ */
|
|
|
|
+ public Builder enableSerialAnnotation() {
|
|
|
|
+ this.entity.serialAnnotation = true;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 开启生成字段常量
|
|
* 开启生成字段常量
|
|
*
|
|
*
|
|
@@ -863,7 +890,7 @@ public class Entity implements ITemplate {
|
|
*
|
|
*
|
|
* @param importPackageFunction 导包处理
|
|
* @param importPackageFunction 导包处理
|
|
* @return this
|
|
* @return this
|
|
- * @since 3.5.10.2
|
|
|
|
|
|
+ * @since 3.5.11
|
|
*/
|
|
*/
|
|
public Builder importPackageFunction(Function<Set<String>, List<String>> importPackageFunction) {
|
|
public Builder importPackageFunction(Function<Set<String>, List<String>> importPackageFunction) {
|
|
this.entity.importPackageFunction = importPackageFunction;
|
|
this.entity.importPackageFunction = importPackageFunction;
|
|
@@ -875,7 +902,7 @@ public class Entity implements ITemplate {
|
|
*
|
|
*
|
|
* @param annotationAttributesFunction 注解处理
|
|
* @param annotationAttributesFunction 注解处理
|
|
* @return this
|
|
* @return this
|
|
- * @since 3.5.10.2
|
|
|
|
|
|
+ * @since 3.5.11
|
|
*/
|
|
*/
|
|
public Builder annotationAttributesFunction(Function<List<? extends AnnotationAttributes>, List<AnnotationAttributes>> annotationAttributesFunction) {
|
|
public Builder annotationAttributesFunction(Function<List<? extends AnnotationAttributes>, List<AnnotationAttributes>> annotationAttributesFunction) {
|
|
this.entity.annotationAttributesFunction = annotationAttributesFunction;
|
|
this.entity.annotationAttributesFunction = annotationAttributesFunction;
|