The @Tolerate annotation is an experimental feature in lombok where the target type is either a Method or a Constructor. The lombok website mentions as:
Any method or constructor can be annotated with @Tolerate and lombok will act as if it does not exist.
It states an example for a setter method:
@Setter
private Date date;
@Tolerate
public void setDate(String date) {
this.date = Date.valueOf(date);
}
In the above example if we had NOT added @Tolerate, then lombok would NOT generate setDate(Date date) because a method of the same name already exists (even though parameter type is different).
So, how it works for a method is clear from this example.
But I am not able to understand how this annotation is to be used for a constructor.
@AllArgsConstructor
public class One {
private int id;
private String name;
// adding @Tolerate here does nothing.
public One(int a, int b) {
}
}
In the above code, lombok would generate an all argument constructor even if another constructor with the same number of parameters but different type exist.
So, how can we use @Tolerate in the context of a constructor?