forked from typetools/checker-framework-inference
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathKeyFor.java
More file actions
43 lines (40 loc) · 1.47 KB
/
Copy pathKeyFor.java
File metadata and controls
43 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package nninf.qual;
import org.checkerframework.framework.qual.SubtypeOf;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Indicates that the annotated reference of an Object that is a key in a map.
*
* <p>The value of the annotation should be the reference name of the map. The following declaration
* for example:
*
* <pre><code>
* Map<String, String> config = ...;
* @KeyFor("config") String key = "HOSTNAME";
*
* String hostname = config.get(key); // known to be non-null
* </code></pre>
*
* indicates that "HOSTNAME" is a key in config. The Nullness checker deduce this information to
* deduce that {@code hostname} reference is a nonnull reference.
*
* <p><b>Limitation</b>: The Nullness checker trusts the user and doesn't validate the annotations.
* Future releases will check for the presence of the key in the map (when possible).
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@SubtypeOf(UnknownKeyFor.class)
public @interface KeyFor {
/**
* Java expression(s) that evaluate to a map for which the annotated type is a key.
*
* @see <a
* href="https://eisop.github.io/cf/manual/manual.html#java-expressions-as-arguments">Syntax
* of Java expressions</a>
*/
public String[] value();
}