diff --git a/spring-core/src/main/java/org/springframework/lang/Contract.java b/spring-core/src/main/java/org/springframework/lang/Contract.java index 6125b10fd8..eff30e21e6 100644 --- a/spring-core/src/main/java/org/springframework/lang/Contract.java +++ b/spring-core/src/main/java/org/springframework/lang/Contract.java @@ -32,34 +32,47 @@ import java.lang.annotation.Target; * been introduce in the {@code org.springframework.lang} package to avoid requiring * an extra dependency, while still following the same semantics. * - *
Method contract has the following syntax:
- * contract ::= (clause ';')* clause
- * clause ::= args '->' effect
- * args ::= ((arg ',')* arg )?
- * arg ::= value-constraint
- * value-constraint ::= 'any' | 'null' | '!null' | 'false' | 'true'
- * effect ::= value-constraint | 'fail'
+ *
Method contract has the following syntax: + *
{@code
+ * contract ::= (clause ';')* clause
+ * clause ::= args '->' effect
+ * args ::= ((arg ',')* arg )?
+ * arg ::= value-constraint
+ * value-constraint ::= '_' | 'null' | '!null' | 'false' | 'true'
+ * effect ::= value-constraint | 'fail' | 'this' | 'new' | 'param'}
*
- * The constraints denote the following:The constraints denote the following: *
_ - any valuenull - null value!null - a value statically proved to be not-nulltrue - true boolean valuefalse - false boolean valuefail - the method throws an exception, if the arguments satisfy argument
- * constraintsThe additional return values denote the following: + *
Examples:
- * @Contract("_, null -> null") - method returns null if its second
- * argument is null
- * @Contract("_, null -> null; _, !null -> !null") - method returns
- * null if its second argument is null and not-null otherwise
- * @Contract("true -> fail") - a typical assertFalse method which
- * throws an exception if true is passed to it
+ *