Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy builder uses getters even when they dont exist #40

Open
AttePietikainen opened this issue Nov 6, 2017 · 0 comments
Open

Copy builder uses getters even when they dont exist #40

AttePietikainen opened this issue Nov 6, 2017 · 0 comments

Comments

@AttePietikainen
Copy link

In the version 1.1.5, the copy builder has started using getX() methods instead of just the field. So if there is a field without a getter function, like most public final fields would not have, the copy builder generated does not work properly.

Say we have the following class

public class Foo {
   public final String bar;
}

This would generate builder like

public static final class Builder {
        private String bar;

        public Builder() {
        }

        public Builder(final Foo copy) {
            this.bar = copy.getBar();
        }

        public Builder withBar(final String bar) {
            this.bar = bar;
            return this;
        }

        public Foo build() {
            return new Foo(this);
        }
    } 

this.bar = copy.getBar();
This part is not valid code as the class does not have getBar function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant