Skip to content

Commit

Permalink
fix #394 needs to be fully qualified and not abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and iocanel committed Jul 4, 2023
1 parent a5689e5 commit 0cf2e19
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,9 @@ private static List<Statement> toInstanceConstructorBody(RichTypeDef clazz, Type
statements.add(new StringStatement("this.fluent = " + fluent + "; "));
}

if (hasDefaultConstructor(clazz)) {
statements.add(new StringStatement("instance = (instance != null ? instance : new " + clazz.getName() + "());\n"));
if (!isAbstract(clazz.toReference()) && hasDefaultConstructor(clazz)) {
statements.add(
new StringStatement("instance = (instance != null ? instance : new " + clazz.getFullyQualifiedName() + "());\n"));
}

StringBuilder builder = new StringBuilder("if (instance != null) {\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2015 The original authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/

package io.sundr.tests;

import io.sundr.builder.annotations.Buildable;

/**
* A simple Pojo that demonstrates default fields are preserved
*/
@Buildable
public abstract class AbstractWithDefaults {

private String field = "Hello";

public String getField() {
return field;
}

public void setField(String field) {
this.field = field;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
* A simple Pojo that demonstrates default fields are preserved
*/
@Buildable
public class WithDefaults {

private String field = "Hello";

public String getField() {
return field;
}

public void setField(String field) {
this.field = field;
}
public class WithDefaults extends AbstractWithDefaults {

}

0 comments on commit 0cf2e19

Please sign in to comment.