• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package checkers.quals;
2 
3 import java.lang.annotation.Annotation;
4 import java.lang.annotation.Documented;
5 import java.lang.annotation.Retention;
6 import java.lang.annotation.RetentionPolicy;
7 
8 /**
9  * Refines the qualified type of the annotated field or variable based on the
10  * qualified type of the receiver.  The annotation declares a relationship
11  * between multiple type qualifier hierarchies.
12  *
13  * <p><b>Example:</b>
14  * Consider a field, {@code lock}, that is only initialized if the
15  * enclosing object (the receiver), is marked as {@code ThreadSafe}.
16  * Such a field can be declared as:
17  *
18  * <pre><code>
19  *   private @Nullable @Dependent(result=NonNull.class, when=ThreadSafe.class)
20  *     Lock lock;
21  * </code></pre>
22  */
23 @Documented
24 @Retention(RetentionPolicy.RUNTIME)
25 //@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
26 public @interface Dependent {
27 
28     /**
29      * The class of the refined qualifier to be applied.
30      */
result()31     Class<? extends Annotation> result();
32 
33     /**
34      * The qualifier class of the receiver that causes the {@code result}
35      * qualifier to be applied.
36      */
when()37     Class<? extends Annotation> when();
38 }
39