mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
OC-11785 @Contract is applicable to constructors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,7 @@ import java.lang.annotation.*;
|
||||
/**
|
||||
* 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.<p>
|
||||
*
|
||||
*
|
||||
* Method contract has the following syntax:<br>
|
||||
* contract ::= (clause ';')* clause<br>
|
||||
* clause ::= args '->' effect<br>
|
||||
@@ -28,7 +28,7 @@ import java.lang.annotation.*;
|
||||
* arg ::= value-constraint<br>
|
||||
* value-constraint ::= 'any' | 'null' | '!null' | 'false' | 'true'<br>
|
||||
* effect ::= value-constraint | 'fail' <p>
|
||||
*
|
||||
*
|
||||
* The constraints denote the following:<br>
|
||||
* <ul>
|
||||
* <li> _ - any value
|
||||
@@ -42,14 +42,14 @@ import java.lang.annotation.*;
|
||||
* <code>@Contract("_, null -> null")</code> - method returns null if its second argument is null<br>
|
||||
* <code>@Contract("_, null -> null; _, !null -> !null")</code> - method returns null if its second argument is null and not-null otherwise<br>
|
||||
* <code>@Contract("true -> fail")</code> - a typical assertFalse method which throws an exception if <code>true</code> is passed to it<br>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Target(ElementType.METHOD)
|
||||
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
public @interface Contract {
|
||||
/**
|
||||
* Contains the contract clauses describing causal relations between call arguments and the returned value
|
||||
* Contains the contract clauses describing causal relations between call arguments and the returned value
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user