@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR}) @ConditionalPostconditionAnnotation(qualifier=KeyFor.class) @InheritedAnnotation @Repeatable(value=EnsuresKeyForIf.List.class) public @interface EnsuresKeyForIf
As an example, consider the following method in java.util.Map
:
@EnsuresKeyForIf(result=true, expression="key", map="this") public boolean containsKey(String key) { ... }If an invocation
m.containsKey(k)
returns true, then the type of k
can be
inferred to be @KeyFor("m")
.KeyFor
,
EnsuresKeyFor
Modifier and Type | Required Element and Description |
---|---|
String[] |
expression
Java expressions that are keys in the given maps after the method returns the given result.
|
String[] |
map |
boolean |
result
The value the method must return, in order for the postcondition to hold.
|
public abstract boolean result
public abstract String[] expression
@JavaExpression @QualifierArgument(value="value") public abstract String[] map