|
23 | 23 | import java.lang.annotation.Target;
|
24 | 24 |
|
25 | 25 | /**
|
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. |
28 | 30 | *
|
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. |
31 | 34 | *
|
32 | 35 | * <p>Method contract has the following syntax:<br/>
|
33 | 36 | * contract ::= (clause ';')* clause<br/>
|
|
39 | 42 | *
|
40 | 43 | * The constraints denote the following:<br/>
|
41 | 44 | * <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> |
48 | 52 | * </ul>
|
49 | 53 | * <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/> |
53 | 60 | *
|
54 | 61 | * @author Sebastien Deleuze
|
55 | 62 | * @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> |
57 | 65 | */
|
58 | 66 | @Documented
|
59 | 67 | @Retention(RetentionPolicy.CLASS)
|
|
0 commit comments