Overload lombok setter

Kartik :

We can use lombok to generate setter like this:

@Data                    //or @Setter
public class Test {  
    int a;
}

Say for instance I also want an overloaded setter that would take a String:

public void setA(String aStr){
    //parseInt and set 'a'
}

But when I add this overloaded method, lombok thinks that I have manually added a setter and so it chooses not to add one itself.

Apparently it looks only at the method name and not the parameters.

Is there a way I can force it to add the normal (that takes an int as parameter) setter?
Or the only way is to add that normal setter myself (using IDE setter generator of course)? I have a lot of fields and a lot of classes.

Kartik :

Adding the @Tolerate annotation on my overloaded method solved the issue.

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.

It has been experimental though, since 2014.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=305054&siteId=1