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

Problem with @Builder and generics #306

Closed
eekboom opened this issue Nov 11, 2016 · 1 comment · Fixed by #330
Closed

Problem with @Builder and generics #306

eekboom opened this issue Nov 11, 2016 · 1 comment · Fixed by #330
Assignees
Milestone

Comments

@eekboom
Copy link

eekboom commented Nov 11, 2016

Have a look at this code:

@Getter
@AllArgsConstructor
class FooFoo {
	private String text;
}

@Getter
class BarBar<T> extends FooFoo {
	private T content;

	@Builder
	public BarBar(String text, T content) {
		super(text);
		this.content = content;
	}
}

class Main {
	public static void main(String[] args) {
		BarBar<BigDecimal> barBar = BarBar.<BigDecimal>builder().text("Hiho").content(BigDecimal.ONE).build();
	}
}

For some reasons my IDE (IntelliJ IDEA) complains about ".content(BigDecimal.ONE)" with "content(T) cannot be applied to content(BigDecimal)".
However the code compiles fine!

When I use the Delombok feature of the plugin, it creates a non-generic builder and the delomboked code does not compile at all.
I need to add parameter to the generated builder to make it work.

@alexejk
Copy link
Collaborator

alexejk commented Jan 3, 2017

Possibly fixed by #329

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