Class ReplaceAnnotatedTypeFactory

All Implemented Interfaces:
AnnotationProvider

public class ReplaceAnnotatedTypeFactory extends ModifiabilityBaseAnnotatedTypeFactory
The annotated type factory for the ReplaceChecker.
  • Constructor Details

    • ReplaceAnnotatedTypeFactory

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

    • typeLacksCapability

      protected boolean typeLacksCapability(TypeMirror type)
      An exact Collection, a Set, a Queue that is not a List, and a non-ListIterator Iterator have no replace methods, so @Modifiable and @Unmodifiable make no claim about them.
      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
    • 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