import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@NonNullByDefault
public class TestClass {
private String testNonNull = "";
@Nullable
private String testNullable;
@Nullable
private String testNullable2;
public void setTestNullable2(@Nullable String testNullable2) {
this.testNullable2 = testNullable2;
}
}
public class Main {
public static void main(String[] args) {
TestClass testClass = new TestClass();
testClass.setTestNonNull(null); // Right - Eclipse says: Null type mismatch: required '@NonNull String' but the provided value is null
testClass.setTestNullable(null); // Wrong - Eclipse says: Null type mismatch: required '@NonNull String' but the provided value is null
testClass.setTestNullable2(null); // Right - Eclipse does not complain.
}
}
It seems contrary to the small print, setTestNullable and setTestNullable2 should be treated the same way?
Regards
Colin
Attention:
The information in this email and in any attachments is confidential. If you are not the intended recipient then please do not distribute, copy or use this information. Please notify us immediately and then delete the message from your computer. Any views or opinions presented are solely those of the author.