Class KeyForValue

  • All Implemented Interfaces:
    AbstractValue<KeyForValue>

    public class KeyForValue
    extends CFAbstractValue<KeyForValue>
    KeyForValue holds additional information about which maps this value is a key for. This extra information is required when adding the @KeyFor qualifier to the type is not a refinement of the type. For example,
         @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).
    • Constructor Detail

      • KeyForValue

        public KeyForValue​(CFAbstractAnalysis<KeyForValue,​?,​?> analysis,
                           AnnotationMirrorSet annotations,
                           javax.lang.model.type.TypeMirror underlyingType)
        Create a KeyForValue.
        Parameters:
        analysis - the analysis
        annotations - the annotations
        underlyingType - the underlying type