Class AbstractCollectionIncompatibleTypeMatcher


public abstract class AbstractCollectionIncompatibleTypeMatcher
extends Object
Extracts the necessary information from a MethodInvocationTree to check whether calls to a method are using incompatible types and to emit a helpful error message.
  • Constructor Details

    • AbstractCollectionIncompatibleTypeMatcher

      public AbstractCollectionIncompatibleTypeMatcher()
  • Method Details

    • matches

      @Nullable public final AbstractCollectionIncompatibleTypeMatcher.MatchResult matches​(com.sun.source.tree.ExpressionTree tree, VisitorState state)
    • extractTypeArgAsMemberOfSupertype

      @Nullable protected static extractTypeArgAsMemberOfSupertype​( type, superTypeSym, int typeArgIndex, types)
      Extracts the appropriate type argument from a specific supertype of the given type. This handles the case when a subtype has different type arguments than the expected type. For example, ClassToInstanceMap<T> implements Map<Class<? extends T>, T>.
      type - the (sub)type from which to extract the type argument
      superTypeSym - the symbol of the supertype on which the type parameter is defined
      typeArgIndex - the index of the type argument to extract from the supertype
      types - the Types utility class from the VisitorState
      the type argument, if defined, or null otherwise
    • message

      protected String message​(AbstractCollectionIncompatibleTypeMatcher.MatchResult result, String sourceType, String targetType)