Class KeyForValue
- All Implemented Interfaces:
AbstractValue<KeyForValue>
@NonNull Object o = map.get(param);
Map<T, Object> map = ...;
<T> T method(T param) {
if (map.contains(param)) {
@NonNull Object o = map.get(param);
return param;
}
}
Inside the if statement, 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).-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.flow.CFAbstractValue
CFAbstractValue.AnnotationSetCombiner, CFAbstractValue.ValueGlb, CFAbstractValue.ValueLub -
Field Summary
Fields inherited from class org.checkerframework.framework.flow.CFAbstractValue
analysis, annotations, atypeFactory, qualHierarchy, underlyingType -
Constructor Summary
ConstructorsConstructorDescriptionKeyForValue(CFAbstractAnalysis<KeyForValue, ?, ?> analysis, AnnotationMirrorSet annotations, TypeMirror underlyingType) Create a KeyForValue. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the maps for which this value is a key.inthashCode()mostSpecific(@Nullable KeyForValue other, @Nullable KeyForValue backup) Returns the more specific of two valuesthisandother.protected KeyForValueupperBound(@Nullable KeyForValue other, TypeMirror upperBoundTypeMirror, boolean shouldWiden) Returns an upper bound ofthisandother.Methods inherited from class org.checkerframework.framework.flow.CFAbstractValue
canBeMissingAnnotations, getAnnotations, getUnderlyingType, greatestLowerBound, hasAnnotationFromEveryHierarchy, leastUpperBound, leastUpperBound, missingAnnotations, toString, toStringFullyQualified, toStringSimple, unionIfLarger, widenUpperBound
-
Constructor Details
-
KeyForValue
public KeyForValue(CFAbstractAnalysis<KeyForValue, ?, ?> analysis, AnnotationMirrorSet annotations, TypeMirror underlyingType) Create a KeyForValue.- Parameters:
analysis- the analysisannotations- the annotationsunderlyingType- the underlying type
-
-
Method Details
-
getKeyForMaps
Returns the maps for which this value is a key.- Returns:
- if the underlying type is a type variable or a wildcard, then the possibly-empty set of maps for which this value is a key; otherwise, null
-
equals
Description copied from class:CFAbstractValueA subclass that adds state must override this method and
CFAbstractValue.hashCode()to account for that state. The dataflow analysis usesequalsto determine whether it has reached a fixed point, so ignoring some state could stop the analysis before that state has stabilized.- Overrides:
equalsin classCFAbstractValue<KeyForValue>
-
hashCode
public int hashCode()- Overrides:
hashCodein classCFAbstractValue<KeyForValue>
-
upperBound
protected KeyForValue upperBound(@Nullable KeyForValue other, TypeMirror upperBoundTypeMirror, boolean shouldWiden) Description copied from class:CFAbstractValueReturns an upper bound ofthisandother. The underlying type of the value returned isupperBoundTypeMirror. IfshouldWidenis false, this method returns the least upper bound ofthisandother.This is the implementation of
CFAbstractValue.leastUpperBound(CFAbstractValue, TypeMirror),CFAbstractValue.leastUpperBound(CFAbstractValue),CFAbstractValue.widenUpperBound(CFAbstractValue), andCFAbstractValue.upperBound(CFAbstractValue, boolean). Subclasses may override it.- Overrides:
upperBoundin classCFAbstractValue<KeyForValue>- Parameters:
other- an abstract valueupperBoundTypeMirror- the underlying type of the returned valueshouldWiden- true if the method should perform widening- Returns:
- an upper bound of this and
other
-
mostSpecific
public @Nullable KeyForValue mostSpecific(@Nullable KeyForValue other, @Nullable KeyForValue backup) Description copied from class:CFAbstractValueReturns the more specific of two valuesthisandother. If they do not contain information for all hierarchies, then it is possible that information from boththisandotherare 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.isSubtypeShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror), then the respective value frombackupis used.- Overrides:
mostSpecificin classCFAbstractValue<KeyForValue>- Parameters:
other- the other value to obtain information frombackup- the value to use ifthisandotherare incomparable- Returns:
- the more specific of two values
thisandother
-