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

[fixes #1498] Respect @Tolerate when using @Singular #3193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erikhofer
Copy link

This fixes #1498 and provides a solution to #1841.

import java.util.List;

import lombok.Builder;
import lombok.Singular;
import lombok.experimental.Tolerate;

@Builder
public class Foo {
	
	public static class FooBuilder {
		
		@Tolerate
		public FooBuilder bar(Integer i) {
			bar(i.toString());
			return this;
		}
	}
	
	@Singular
	private final List<String> bars;
}

This code currently produces the following error: Manually adding a method that @Singular @Builder would generate is not supported. If you want to manually manage the builder aspect for this field/parameter, don't use @Singular.

With this fix, it is possible to manually suppress this error with @Tolerate. It enables adding convenience methods with the same name as the generated methods.

@rzwitserloot
Copy link
Collaborator

Hmm, I'm not sure we want to allow this, but I'm having a hard time coming up with arguments that sound good. I dislike having to trust my gut if my brain can't come up with objective reasons.

Hey @rspilker 's gut and brain, how do you two feel about this?

@Rawi01
Copy link
Collaborator

Rawi01 commented May 19, 2022

@Tolerate documentation:

Put on any method or constructor to make lombok pretend it doesn't exist, i.e., to generate a method which would otherwise be skipped due to possible conflicts.

I think it is reasonable to assume that someone tries to add this annotation and I also don't know a reason why it should not work. If we add this I would propose to also change the error message e.g. or add the experimental @Tolerate annotation to your method. If we don't allow this we should update the @Tolerate documentation

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

Successfully merging this pull request may close these issues.

@Tolerate should work with @Singular
3 participants