[johnzon] branch master updated: try to have more java friendly names in PojoGenerator - bad completion
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 62dbff7b try to have more java friendly names in PojoGenerator - bad completion 62dbff7b is described below commit 62dbff7b08764c98bf7b1dff8e437322d073a51d Author: Romain Manni-Bucau AuthorDate: Mon Aug 8 17:33:26 2022 +0200 try to have more java friendly names in PojoGenerator - bad completion --- .../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 29316bec..9fd9f4c4 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 @@ -563,7 +563,7 @@ public class PojoGenerator { boolean up = true; for (final char c : name.toCharArray()) { if (up) { -out.append(Character.isUpperCase(c)); +out.append(Character.toUpperCase(c)); up = false; } else if (c == '_') { up = true;
[johnzon] branch master updated: try to have more java friendly names in PojoGenerator
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 544311af try to have more java friendly names in PojoGenerator 544311af is described below commit 544311af11052adaa686368c8cf8b1a57935c024 Author: Romain Manni-Bucau AuthorDate: Mon Aug 8 17:31:53 2022 +0200 try to have more java friendly names in PojoGenerator --- .../johnzon/jsonschema/generator/PojoGenerator.java | 20 1 file changed, 20 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 62bb2ccb..29316bec 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 @@ -548,12 +548,32 @@ public class PojoGenerator { name += "Value"; } +if (name.contains("_")) { +name = toCamelCase(name); +} + if (!Objects.equals(key, name) && configuration.isAddJsonbProperty()) { imports.add(JsonbProperty.class.getName()); } return name; } +protected String toCamelCase(final String name) { +final StringBuilder out = new StringBuilder(name.length()); +boolean up = true; +for (final char c : name.toCharArray()) { +if (up) { +out.append(Character.isUpperCase(c)); +up = false; +} else if (c == '_') { +up = true; +} else { +out.append(c); +} +} +return out.toString(); +} + protected boolean isReserved(final String name) { return "continue".equals(name) || "break".equals(name) || "default".equals(name) || "do".equals(name) || "while".equals(name) ||