helospark / SparkBuilderGenerator

Eclipse plugin to generate builders
MIT License
38 stars 12 forks source link

Compile error on generated builder code concerning fields from superclass #64

Closed hbrands closed 2 years ago

hbrands commented 2 years ago

Activate the following two options:

With this input

public class TestBean {
    private String invisible;
    private Integer count;
    public Integer getCount() {
        return count;
    }
    public void setCount(Integer count) {
        this.count = count;
    }
}
public class DerivedBean extends TestBean {
    private String name;
}

generating the builder for DerivedBean including fields name and count (from superclass) the generated builder constructor with parameter DerivedBean does not compile:

        private Builder(DerivedBean derivedBean) {
            this.name = derivedBean.name;
            this.count = derivedBean.count; // <-- error: The field TestBean.count is not visible
        }

In my opinion, in this case the generated code should look like:

        private Builder(DerivedBean derivedBean) {
            this.name = derivedBean.name;
            this.count = derivedBean.getCount(); // <-- use getter here
        }

If there is no visible getter for the field, it should probably be omitted.

helospark commented 2 years ago

Hello! Thanks for reporting this, I'll going to fix it next week.

helospark commented 2 years ago

Fix released in 0.0.26, please check.

hbrands commented 2 years ago

My test was successful with version 0.0.26. Thanks!