Open Shadow-Devil opened 1 month ago
This would also enable developers to write @Contract
s which describes how methods behave to different inputs.
Examples:
@Contract("null -> null")
if you provide a null to this method it will return null@Contract("-> new")
this method will create a new object and return it@Contract("null -> fail")
this method will throw an exception if you provide a null value.@Contract("true -> fail")
a typical assertFalse method which throws an exception if true
is passed to it
Description
There is already some small usage of this dependency in the
jballerina-unit-test
module (here and here) but it is only via a transitive dependency of the kotlin std lib.It would be great to add this dependency directly to the
javaProject.gradle
compileOnly
scope, so it can be used everywhere (without adding any runtime overhead or increasing the distribution size).There are other options for
@Nullable
annotations, e.g.but since the JetBrains annotations are already used I think these should be adopted. This would help will NPEs since nullable values can be annotated and therefore better documented. Also IntelliJ and Spotbugs use these annotations in static analysis.
Describe your problem(s)
There is currently no standard defined to document nullable values in the project.
Describe your solution(s)
Add this dependency to the
compileOnly
scope of thejavaProject.gradle
file.Related area
-> Other Area
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response