@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
Returns Java expressions whose values are maps, each of which contains each expression value as
a key (after the method returns the given result).
|
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