Class SeqGrowAnnotatedTypeFactory

All Implemented Interfaces:
AnnotationProvider

public class SeqGrowAnnotatedTypeFactory extends ModifiabilityBaseAnnotatedTypeFactory
The annotated type factory for the SeqGrowChecker.
  • Constructor Details

    • SeqGrowAnnotatedTypeFactory

      public SeqGrowAnnotatedTypeFactory(BaseTypeChecker checker)
      Creates a SeqGrowAnnotatedTypeFactory.
      Parameters:
      checker - the associated type-checker
  • Method Details

    • typeLacksCapability

      protected boolean typeLacksCapability(TypeMirror type)
      Only sequenced collections and sequenced maps have sequenced-grow methods, so @Modifiable and @Unmodifiable make no claim about any other type. This is an allowlist, unlike the blocklists of the other capabilities.

      On JDKs before Java 21, SequencedCollection and SequencedMap are not present, but Deque still has first/last insertion methods.

      Overrides:
      typeLacksCapability in class ModifiabilityBaseAnnotatedTypeFactory
      Parameters:
      type - the type on which an alias was written; it is an upper bound, so it is never a type variable or a wildcard, and ModifiabilityBaseAnnotatedTypeFactory.lacksCapability(javax.lang.model.type.TypeMirror, java.util.function.Predicate<javax.lang.model.type.TypeMirror>) has already decomposed intersection types, so it is never an intersection type either
      Returns:
      true if type structurally cannot support this checker's capability
    • typesWithCapability

      protected List<TypeMirror> typesWithCapability()
      Description copied from class: ModifiabilityBaseAnnotatedTypeFactory
      Returns erased types whose every subtype has this checker's capability, unless ModifiabilityBaseAnnotatedTypeFactory.typeLacksCapability(javax.lang.model.type.TypeMirror) holds of the subtype. For example, the Replace Checker's result includes List.

      A type variable or wildcard may be instantiated by any subtype of its upper bound, including a subtype that also implements an unrelated interface. For example, a type variable whose upper bound is AbstractCollection or Serializable may be instantiated by HashSet, which cannot be replaced into. So an alias written on a type variable claims this checker's capability only if the upper bound is a subtype of one of these types.

      Specified by:
      typesWithCapability in class ModifiabilityBaseAnnotatedTypeFactory
      Returns:
      erased types whose subtypes have this checker's capability
    • polyLacksCapability

      protected boolean polyLacksCapability(TypeMirror type)
      For Map.Entry, only the replace bit is meaningful to carry from the map receiver, so the sequenced-grow bit of @PolyModifiable is @MaybeSeqGrowable.
      Overrides:
      polyLacksCapability in class ModifiabilityBaseAnnotatedTypeFactory
      Parameters:
      type - the type on which @PolyModifiable was written; it is an upper bound, so it is never a type variable or a wildcard, and ModifiabilityBaseAnnotatedTypeFactory.lacksCapability(javax.lang.model.type.TypeMirror, java.util.function.Predicate<javax.lang.model.type.TypeMirror>) has already decomposed intersection types, so it is never an intersection type either
      Returns:
      true if @PolyModifiable weakens to the top qualifier on type