Skip to content

Commit da89251

Browse files
committed
Polish @Contract Javadoc
1 parent 09d87fa commit da89251

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

spring-core/src/main/java/org/springframework/lang/Contract.java

+22-14
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* Inspired from {@code org.jetbrains.annotations.Contract}, this variant has been introduce in the
27-
* {@code org.springframework.lang} package to avoid requiring an extra dependency, while still following the same semantics.
26+
* <p>Specifies some aspects of the method behavior depending on the arguments.
27+
* Can be used by tools for advanced data flow analysis. Note that this annotation
28+
* just describes how the code works and doesn't add any functionality by means of
29+
* code generation.
2830
*
29-
* <p>Specifies some aspects of the method behavior depending on the arguments. Can be used by tools for advanced data flow analysis.
30-
* Note that this annotation just describes how the code works and doesn't add any functionality by means of code generation.
31+
* <p>Inspired from {@code org.jetbrains.annotations.Contract}, this variant has
32+
* been introduce in the {@code org.springframework.lang} package to avoid requiring
33+
* an extra dependency, while still following the same semantics.
3134
*
3235
* <p>Method contract has the following syntax:<br/>
3336
* contract ::= (clause ';')* clause<br/>
@@ -39,21 +42,26 @@
3942
*
4043
* The constraints denote the following:<br/>
4144
* <ul>
42-
* <li> _ - any value
43-
* <li> null - null value
44-
* <li> !null - a value statically proved to be not-null
45-
* <li> true - true boolean value
46-
* <li> false - false boolean value
47-
* <li> fail - the method throws an exception, if the arguments satisfy argument constraints
45+
* <li> <code>_</code> - any value</li>
46+
* <li> <code>null</code> - null value</li>
47+
* <li> <code>!null</code> - a value statically proved to be not-null</li>
48+
* <li> <code>true</code> - true boolean value</li>
49+
* <li> <code>false</code> - false boolean value</li>
50+
* <li> <code>fail</code> - the method throws an exception, if the arguments satisfy argument
51+
* constraints</li>
4852
* </ul>
4953
* <p>Examples:
50-
* <code>@Contract("_, null -> null")</code> - method returns null if its second argument is null<br/>
51-
* <code>@Contract("_, null -> null; _, !null -> !null")</code> - method returns null if its second argument is null and not-null otherwise<br/>
52-
* <code>@Contract("true -> fail")</code> - a typical assertFalse method which throws an exception if <code>true</code> is passed to it<br/>
54+
* <code>@Contract("_, null -> null")</code> - method returns null if its second
55+
* argument is null<br/>
56+
* <code>@Contract("_, null -> null; _, !null -> !null")</code> - method returns
57+
* null if its second argument is null and not-null otherwise<br/>
58+
* <code>@Contract("true -> fail")</code> - a typical assertFalse method which
59+
* throws an exception if <code>true</code> is passed to it<br/>
5360
*
5461
* @author Sebastien Deleuze
5562
* @since 6.2
56-
* @see <a href="https://github.com/uber/NullAway/wiki/Configuration#custom-contract-annotations">NullAway custom contract annotations</a>
63+
* @see <a href="https://github.com/uber/NullAway/wiki/Configuration#custom-contract-annotations">
64+
* NullAway custom contract annotations</a>
5765
*/
5866
@Documented
5967
@Retention(RetentionPolicy.CLASS)

0 commit comments

Comments
 (0)