@Documented @Retention(CLASS) @Target(METHOD) public @interface Contract
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'
The constraints denote the following:
@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
| Modifier and Type | Optional Element | Description |
|---|---|---|
boolean |
pure |
Specifies that the annotated method has no visible side effects, in the following sense.
|
String |
value |
Contains the contract clauses describing causal relations between call arguments and the returned value
|
String value
boolean pure
Copyright © 2018 MARID software development group. All rights reserved.