|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Documented @Retention(value=CLASS) @Target(value=METHOD) public @interface Contract
Specifies some aspects of the method behavior depending on the arguments. Can be used by tools for advanced data flow analysis. Note that this annotation just describes how the code works and doesn't add any functionality by means of code generation.
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'
@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
| Optional Element Summary | |
|---|---|
boolean |
pure
Specifies if this method is pure, i.e. |
String |
value
Contains the contract clauses describing causal relations between call arguments and the returned value |
public abstract String value
public abstract boolean pure
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||