diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertiesRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertiesRule.java index 76aef50ca..64b56df11 100644 --- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertiesRule.java +++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/PropertiesRule.java @@ -83,15 +83,18 @@ private void addOverrideBuilders(JDefinedClass jclass, JDefinedClass parentJclas } } - private JMethod addOverrideBuilder(JDefinedClass thisJDefinedClass, JMethod parentBuilder, JVar parentParam) { - JMethod builder = thisJDefinedClass.method(parentBuilder.mods().getValue(), thisJDefinedClass, parentBuilder.name()); - builder.annotate(Override.class); - - JVar param = builder.param(parentParam.type(), parentParam.name()); - JBlock body = builder.body(); - body.invoke(JExpr._super(), parentBuilder).arg(param); - body._return(JExpr._this()); - - return builder; + private void addOverrideBuilder(JDefinedClass thisJDefinedClass, JMethod parentBuilder, JVar parentParam) { + + if (thisJDefinedClass.getMethod(parentBuilder.name(), new JType[] {parentParam.type()}) == null) { + + JMethod builder = thisJDefinedClass.method(parentBuilder.mods().getValue(), thisJDefinedClass, parentBuilder.name()); + builder.annotate(Override.class); + + JVar param = builder.param(parentParam.type(), parentParam.name()); + JBlock body = builder.body(); + body.invoke(JExpr._super(), parentBuilder).arg(param); + body._return(JExpr._this()); + + } } } diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java index 7ddca924d..70992698f 100644 --- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java +++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CompilerWarningIT.java @@ -105,7 +105,7 @@ public void checkWarnings() { } public static List> warnings(List> all) { - List> warnings = new ArrayList<>(); + List> warnings = new ArrayList>(); for( Diagnostic entry : all ) { if( entry.getKind() == Kind.WARNING ) { warnings.add(entry); diff --git a/jsonschema2pojo-integration-tests/src/test/resources/schema/extends/subtypeOfSubtypeOfA.json b/jsonschema2pojo-integration-tests/src/test/resources/schema/extends/subtypeOfSubtypeOfA.json index efd5808f7..51ae059fb 100644 --- a/jsonschema2pojo-integration-tests/src/test/resources/schema/extends/subtypeOfSubtypeOfA.json +++ b/jsonschema2pojo-integration-tests/src/test/resources/schema/extends/subtypeOfSubtypeOfA.json @@ -4,6 +4,9 @@ "$ref": "subtypeOfA.json" }, "properties": { + "parent" : { + "type": "string" + }, "child": { "type": "string" }