Lombok-intellij-plugin: Can't correctly resolve multiple @Builder methods in same class having partial implementations

Created on 13 Dec 2015  路  8Comments  路  Source: mplushnikov/lombok-intellij-plugin

It seems that the plugin doesn't correctly process the @Builder annotation when it's applied to a second method in the same class _and_ there are already partial implementations of the builders.

Here are two screenshots of the same class with the Builder definitions inverted:

person_builder
method declaration reversed:
pet_builder
Similarly, trying to resolve method declarations from an external class (when PersonBuilder is the one correctly generated):
Resolving PersonBuilder:
screen shot 2015-12-12 at 6 06 35 pm
Resolving incorrectly for PetBuilder:
screen shot 2015-12-12 at 6 07 02 pm

Thanks!

bug

Most helpful comment

Not sure that it's still relevant, but I've encountered the same issue and resolved this by specifically setting the builderClassName

@Builder(builderMethodName = "relaxedBuilder", builderClassName = "RelaxedBuilder") 
private MyClass( ... )

@Builder(builderMethodName = "builder") 
private MyClass( ... )

and usage:

MyClass.builder()

MyClass.relaxedBuilder()

All 8 comments

Thank you for good description/example. I'll investigate this issue.

Found the cause of the problem and I'll provide correct behaviour in the next version!

Great! Thanks!

Plugin 0.9.8 was released today

@sg-ad I was trying to use two @Builder for two different methods, aBuilder and bBuilder, in a single TestUtils class, but when I call the bBuilder and run the test, aBuilder was called instead? Have you run into this problem?

I run into the same issue as the one from jl4347 :
With multiple @Builder methods in same class having same return type and same buildMethodName, whatever builder I call, only the first one is called.

I'm running in to this as well with 2 different method names.

Not sure that it's still relevant, but I've encountered the same issue and resolved this by specifically setting the builderClassName

@Builder(builderMethodName = "relaxedBuilder", builderClassName = "RelaxedBuilder") 
private MyClass( ... )

@Builder(builderMethodName = "builder") 
private MyClass( ... )

and usage:

MyClass.builder()

MyClass.relaxedBuilder()
Was this page helpful?
0 / 5 - 0 ratings