Files
openide/plugins/lombok/testData/highlights/with/WitherExample.java
Michail Plushnikov 5640847303 [lombok] IDEA-366441 Fix Intellij warnings for Lombok @With annotation functionality on class
GitOrigin-RevId: 3eeeeeeff7b4c510bcfd835a1b6eec7037a6fcc5
2025-02-11 23:24:15 +00:00

47 lines
1.9 KiB
Java

import lombok.Getter;
import lombok.With;
@With
@Getter
public class WitherExample {
private String matchingTypeParameter;
private String differentTypeParameter;
public WitherExample() {
this.matchingTypeParameter = null;
this.differentTypeParameter = null;
}
public WitherExample(String matchingTypeParameter, String differentTypeParameter) {
this.matchingTypeParameter = matchingTypeParameter;
this.differentTypeParameter = differentTypeParameter;
}
/*
* Intellij GUI displays a compilation warning for this method when it should not.
* The warning states that the same method signature is already defined in the class (Lombok @With),
* however this is not the case when actually compiled.
* The method `withMatchingTypeParameter(String matchingTypeParameter)` is never generated by Lombok as the below method is defined with the same name.
*/
public WitherExample withMatchingTypeParameter(String matchingTypeParameter) {
this.matchingTypeParameter = matchingTypeParameter;
return this;
}
/*
* When calling this method Intellij GUI displays two options when it should only display one
* An option is given for `withDifferentTypeParameter(String differentTypeParameter)`,
* however that method is never generated by Lombok as the below method is defined with the same name.
*/
public WitherExample withDifferentTypeParameter(int differentTypeParameter) {
this.differentTypeParameter = String.valueOf(differentTypeParameter);
return this;
}
public static void main(String[] args) {
WitherExample underTest = new WitherExample("value", "123");
underTest.withDifferentTypeParameter(1);
underTest.withDifferentTypeParameter<error descr="'withDifferentTypeParameter(int)' in 'WitherExample' cannot be applied to '(java.lang.String)'">("not valid")</error>;
}
}