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

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


The following commit(s) were added to refs/heads/master by this push:
     new ca39ffc8 [JOHNZON-387] enum extension points in PojoGenerator
ca39ffc8 is described below

commit ca39ffc8e45b0c9d4e407a35297e3740b6342737
Author: Romain Manni-Bucau <rmannibu...@gmail.com>
AuthorDate: Tue Aug 9 10:25:28 2022 +0200

    [JOHNZON-387] enum extension points in PojoGenerator
---
 .../johnzon/jsonschema/generator/PojoGenerator.java      | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java
 
b/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java
index 00989c38..c50c4af2 100644
--- 
a/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java
+++ 
b/johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java
@@ -198,6 +198,10 @@ public class PojoGenerator {
         return null; // todo: check if already in nested for ex
     }
 
+    protected String beforeEnumEnd() {
+        return "";
+    }
+
     protected String beforeClassEnd() {
         return "";
     }
@@ -206,6 +210,14 @@ public class PojoGenerator {
         return "";
     }
 
+    protected String afterEnumName() {
+        return "";
+    }
+
+    protected String enumImports() {
+        return "";
+    }
+
     protected String asType(final String javaName, final JsonObject schema, 
final boolean required) {
         final JsonValue ref = schema.get("$ref");
         if (ref != null && ref.getValueType() == JsonValue.ValueType.STRING) {
@@ -316,7 +328,8 @@ public class PojoGenerator {
                 configuration.getPackageName().replace('.', '/') + '/' + 
className + ".java", "" +
                         "package " + configuration.getPackageName() + ";\n" +
                         "\n" +
-                        "public enum " + className + " {\n" +
+                        enumImports() +
+                        "public enum " + className + afterEnumName() + " {\n" +
                         values.entrySet().stream()
                                 .map(it -> "" +
                                         (injectValues && 
configuration.isAddJsonbProperty() ?
@@ -338,6 +351,7 @@ public class PojoGenerator {
                                         "    }\n" +
                                         "" :
                                 "") +
+                        beforeEnumEnd() +
                         "}\n");
         return className;
     }

Reply via email to