We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
public class BuilderAnnotationTest { @Test public void defalutValue() throws Exception { assertThat(Entity.builder().build().isSingle()).isTrue(); } } @Getter @Builder class Entity{ private String name; private boolean single = true; }
The text was updated successfully, but these errors were encountered:
Duplicate of #916. There's a workaround
@Getter @Builder(toBuilder=true) @AllArgsConstructor @NoArgsConstructor(access=AccessLevel.PRIVATE) public class Entity { public static EntityBuilder builder() { return PROTOTYPE.toBuilder(); } private static final Entity PROTOTYPE = new Entity(); private String name; private boolean single = true; }
Sorry, something went wrong.
This also works
public class BuilderAnnotationTest { @Test public void defalutValue() throws Exception { assertThat(new Entity().toBuilder().build().isSingle()).isTrue(); // note the "new" here } } @Getter @Builder(toBuilder = true) class Entity{ private String name; private boolean single = true; }
Use @Builder.Default to fix this problem.
@Builder.Default
No branches or pull requests
The text was updated successfully, but these errors were encountered: