From a8881a3e3490e81cb776a68028ad8ad9c5218e41 Mon Sep 17 00:00:00 2001 From: jiri-meluzin Date: Sun, 22 Sep 2024 22:20:27 +0200 Subject: [PATCH] Fixed generics in base builder => no more warnings (#1587) Co-authored-by: meluzinj --- .../src/main/java/org/jsonschema2pojo/rules/BuilderRule.java | 2 +- .../src/main/java/org/jsonschema2pojo/rules/PropertyRule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/BuilderRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/BuilderRule.java index d64234b15..5695ed2e4 100644 --- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/BuilderRule.java +++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/BuilderRule.java @@ -110,7 +110,7 @@ public JDefinedClass apply(String nodeName, JsonNode node, JsonNode parent, JDef generateNoArgsBuilderConstructors(instanceClass, builderClass, concreteBuilderClass); } - JMethod builderMethod = instanceClass.method(JMod.PUBLIC + JMod.STATIC, builderClass, "builder"); + JMethod builderMethod = instanceClass.method(JMod.PUBLIC + JMod.STATIC, builderClass.narrow(instanceClass.wildcard()), "builder"); JBlock builderBody = builderMethod.body(); builderBody._return(JExpr._new(concreteBuilderClass)); diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java index 9bb0ecb72..79a70b99b 100644 --- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java +++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertyRule.java @@ -290,7 +290,7 @@ private JMethod addLegacyBuilder(JDefinedClass c, JFieldVar field, String jsonPr private JMethod addInnerBuilderMethod(JDefinedClass c, JFieldVar field, String jsonPropertyName, JsonNode node) { JDefinedClass builderClass = ruleFactory.getReflectionHelper().getBaseBuilderClass(c); - JMethod builderMethod = builderClass.method(JMod.PUBLIC, builderClass, getBuilderName(jsonPropertyName, node)); + JMethod builderMethod = builderClass.method(JMod.PUBLIC, builderClass.narrow(builderClass.typeParams()), getBuilderName(jsonPropertyName, node)); JVar param = builderMethod.param(field.type(), field.name()); JBlock body = builderMethod.body();