[johnzon] branch master updated: PojoGenerator extension point before declaration

2022-08-09 Thread rmannibucau
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 60ba23ca PojoGenerator extension point before declaration
60ba23ca is described below

commit 60ba23cac6ac770e9f7edb4301c4ec5d492d2481
Author: Romain Manni-Bucau 
AuthorDate: Tue Aug 9 10:44:55 2022 +0200

PojoGenerator extension point before declaration
---
 .../org/apache/johnzon/jsonschema/generator/PojoGenerator.java | 10 ++
 1 file changed, 10 insertions(+)

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 5db62394..0f0ba037 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
@@ -77,6 +77,7 @@ public class PojoGenerator {
 .sorted()
 .map(it -> "import " + it + ";")
 .collect(joining("\n", "", "\n\n"))) +
+beforeClassDeclaration() +
 "public class " + configuration.getClassName() + 
afterClassName() + " {\n" +
 (attributes.isEmpty() ?
 ("" +
@@ -223,6 +224,14 @@ public class PojoGenerator {
 return "";
 }
 
+protected String beforeEnumDeclaration() {
+return "";
+}
+
+protected String beforeClassDeclaration() {
+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) {
@@ -334,6 +343,7 @@ public class PojoGenerator {
 "package " + configuration.getPackageName() + ";\n" +
 "\n" +
 enumImports() +
+beforeEnumDeclaration() +
 "public enum " + className + afterEnumName(values, 
injectValues) + " {\n" +
 values.entrySet().stream()
 .map(it -> "" +



[johnzon] 02/02: [JOHNZON-387] inject more data in afterEnumName to avoid subclasses to recompute it

2022-08-09 Thread rmannibucau
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

commit f4d074be27122e7bf022c64b1f37704fcb84b42c
Author: Romain Manni-Bucau 
AuthorDate: Tue Aug 9 10:31:33 2022 +0200

[JOHNZON-387] inject more data in afterEnumName to avoid subclasses to 
recompute it
---
 .../org/apache/johnzon/jsonschema/generator/PojoGenerator.java   | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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 7264ddc5..5db62394 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
@@ -210,7 +210,12 @@ public class PojoGenerator {
 return "";
 }
 
-protected String afterEnumName() {
+/**
+ * @param values the enum values (key is json name, value is java name).
+ * @param valuesAreInjected is there a toString() with json name or is the 
enum anemic (only values, no method)
+ * @return the data to add after enum name and before the opening brace in 
enum declaration.
+ */
+protected String afterEnumName(final Map values, final 
boolean valuesAreInjected) {
 return "";
 }
 
@@ -329,7 +334,7 @@ public class PojoGenerator {
 "package " + configuration.getPackageName() + ";\n" +
 "\n" +
 enumImports() +
-"public enum " + className + afterEnumName() + " {\n" +
+"public enum " + className + afterEnumName(values, 
injectValues) + " {\n" +
 values.entrySet().stream()
 .map(it -> "" +
 (injectValues && 
configuration.isAddJsonbProperty() ?



[johnzon] 01/02: [JOHNZON-387] expose toJavaName to subclasses in PojoGenerator

2022-08-09 Thread rmannibucau
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

commit c98558803b72a5ddf32c62ca1cdd523a95ca72cb
Author: Romain Manni-Bucau 
AuthorDate: Tue Aug 9 10:29:54 2022 +0200

[JOHNZON-387] expose toJavaName to subclasses in PojoGenerator
---
 .../java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java | 2 +-
 1 file changed, 1 insertion(+), 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 c50c4af2..7264ddc5 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
@@ -544,7 +544,7 @@ public class PojoGenerator {
 return JsonValue.class.getSimpleName();
 }
 
-private String toJavaName(final String key) {
+protected String toJavaName(final String key) {
 String name = key.chars()
 .mapToObj(i -> 
Character.toString(!Character.isJavaIdentifierPart(i) ? '_' : (char) i))
 .collect(joining());



[johnzon] branch master updated (ca39ffc8 -> f4d074be)

2022-08-09 Thread rmannibucau
This is an automated email from the ASF dual-hosted git repository.

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


from ca39ffc8 [JOHNZON-387] enum extension points in PojoGenerator
 new c9855880 [JOHNZON-387] expose toJavaName to subclasses in PojoGenerator
 new f4d074be [JOHNZON-387] inject more data in afterEnumName to avoid 
subclasses to recompute it

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/johnzon/jsonschema/generator/PojoGenerator.java| 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)



[johnzon] branch master updated: [JOHNZON-387] enum extension points in PojoGenerator

2022-08-09 Thread rmannibucau
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 
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;
 }