I saw the work being done to add @Contract
annotations for null-safety analysis (#32475).
Having a look at the updates to org.springframework.util.Assert
methods, I wonder why for example hasText
was not annotated with @Contract(null,_ -> fail)
, although hasText
would also throw an exception in case of null
.
I'm often using only Assert.hasText
for incoming @Nullable
strings to ensure a non-null value afterwards. Unfortunately IntelliJ does not recognize this method correctly, like it does for Assert.notNull
.
For now I need to add another notNull
check in the code or use 'external contract annotations' in IntelliJ, which is quite cumbersome.
It would be great if @Contract
annotations could be added to the remaining Assert
methods as well to avoid this in the future hoping that they would then also be recognized by IntelliJ correctly).