Class ShrinkAnnotatedTypeFactory

All Implemented Interfaces:
AnnotationProvider

public class ShrinkAnnotatedTypeFactory extends ModifiabilityBaseAnnotatedTypeFactory
The annotated type factory for the ShrinkChecker.
  • Constructor Details

    • ShrinkAnnotatedTypeFactory

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

    • typeLacksCapability

      protected boolean typeLacksCapability(TypeMirror type)
      Map.Entry has no shrink methods, so @Modifiable and @Unmodifiable make no claim about it.
      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 shrink bit of @PolyModifiable is @MaybeShrinkable.
      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
    • refinedIteratorResultBound

      protected @Nullable TypeMirror refinedIteratorResultBound()
      Description copied from class: ModifiabilityBaseAnnotatedTypeFactory
      Returns the erased type that the result of an iterator method must be a subtype of for this checker to refine the result, or null if this checker does not refine iterator results. The Shrink Checker refines the result of iterator() and listIterator(); the Grow and Replace Checkers refine only the result of listIterator(), because a plain Iterator can neither grow nor replace.
      Overrides:
      refinedIteratorResultBound in class ModifiabilityBaseAnnotatedTypeFactory
      Returns:
      the erased upper bound of the iterator results this checker refines, or null