public class KeyForValue extends CFAbstractValue<KeyForValue>
Inside the if statement,Map<T, Object> map = ...;
<T> T method(T param) { } if (map.contains(param) { {@code @NonNull Object o = map.get(param);} return param; }
}
param
is a key for "map". This would normally be represented as
@KeyFor("map") T
, but this is not a subtype of T
, so the type cannot be refined.
Instead, the value for param
includes "map" in the list of keyForMaps. This information
is used in KeyForAnnotatedTypeFactory.isKeyForMap(String, ExpressionTree)
.CFAbstractValue.AnnotationSetAndTypeMirrorVisitor
analysis, annotations, underlyingType
Constructor and Description |
---|
KeyForValue(CFAbstractAnalysis<KeyForValue,?,?> analysis,
Set<AnnotationMirror> annotations,
TypeMirror underlyingType)
Create an instance.
|
Modifier and Type | Method and Description |
---|---|
Set<String> |
getKeyForMaps()
If the underlying type is a type variable or a wildcard, then this is a set of maps for which
this value is a key.
|
KeyForValue |
leastUpperBound(KeyForValue other)
Compute the least upper bound of two stores.
|
KeyForValue |
mostSpecific(KeyForValue other,
KeyForValue backup)
Returns the more specific version of two values
this and other . |
canBeMissingAnnotations, equals, getAnnotations, getUnderlyingType, hashCode, toString, validateSet, widenUpperBound
public KeyForValue(CFAbstractAnalysis<KeyForValue,?,?> analysis, Set<AnnotationMirror> annotations, TypeMirror underlyingType)
public Set<String> getKeyForMaps()
public KeyForValue leastUpperBound(KeyForValue other)
AbstractValue
Important: This method must fulfill the following contract:
this
.
other
.
this
, even if the signature is
more permissive.
leastUpperBound
in interface AbstractValue<KeyForValue>
leastUpperBound
in class CFAbstractValue<KeyForValue>
public KeyForValue mostSpecific(KeyForValue other, KeyForValue backup)
CFAbstractValue
this
and other
. If they do
not contain information for all hierarchies, then it is possible that information from both
this
and other
are taken.
If neither of the two is more specific for one of the hierarchies (i.e., if the two are
incomparable as determined by QualifierHierarchy.isSubtype(AnnotationMirror,
AnnotationMirror)
, then the respective value from backup
is used.
mostSpecific
in class CFAbstractValue<KeyForValue>