You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2022/11/24 13:55:13 UTC

[cayenne] 01/02: CAY-2780 Modeler: Multiple configurations for classes generation

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit a80f946735c00e43203a25d55828a3d885191594
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Thu Nov 24 16:54:07 2022 +0300

    CAY-2780 Modeler: Multiple configurations for classes generation
---
 .../org/apache/cayenne/gen/CgenConfiguration.java  |  5 +++--
 .../java/org/apache/cayenne/gen/CgenTemplate.java  | 23 ++++++++++++++++++----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
index 142e77be0..221b1adff 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenConfiguration.java
@@ -92,6 +92,7 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
     private String externalToolConfig;
 
     public CgenConfiguration() {
+        this.name = CgenConfigList.DEFAULT_CONFIG_NAME;
         /*
          * {@link #isDefault()} method should be in sync with the following values
          */
@@ -451,8 +452,8 @@ public class CgenConfiguration implements Serializable, XMLSerializable {
                 && !createPKProperties
                 && !createPropertyNames
                 && "*.java".equals(outputPattern)
-                && template.equals(TemplateType.ENTITY_SUBCLASS.pathFromSourceRoot())
-                && superTemplate.equals(TemplateType.ENTITY_SUPERCLASS.pathFromSourceRoot())
+                && template.equals(TemplateType.ENTITY_SUBCLASS.defaultTemplate())
+                && superTemplate.equals(TemplateType.ENTITY_SUPERCLASS.defaultTemplate())
                 && (superPkg == null || superPkg.isEmpty())
                 && (externalToolConfig == null || externalToolConfig.isEmpty());
     }
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenTemplate.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenTemplate.java
index 2100693cf..18e037968 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenTemplate.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenTemplate.java
@@ -19,18 +19,20 @@
 
 package org.apache.cayenne.gen;
 
+import java.util.Objects;
+
 /**
  * @since 5.0
  */
 public class CgenTemplate {
     private final String data;
     private final boolean isFile;
-    private TemplateType type;
+    private final TemplateType type;
 
-    public CgenTemplate(String data, Boolean isFile, TemplateType type) {
-        this.data = data;
+    public CgenTemplate(String data, boolean isFile, TemplateType type) {
+        this.data = Objects.requireNonNull(data);
         this.isFile = isFile;
-        this.type = type;
+        this.type = Objects.requireNonNull(type);
     }
 
     public String getData() {
@@ -52,4 +54,17 @@ public class CgenTemplate {
     public TemplateType getType() {
         return type;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        CgenTemplate that = (CgenTemplate) o;
+        return isFile == that.isFile && type == that.type && data.equals(that.data);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(data, isFile, type);
+    }
 }