Class TypeArgumentMapper
- java.lang.Object
-
- org.checkerframework.framework.util.TypeArgumentMapper
-
public class TypeArgumentMapper extends java.lang.Object
Records any mapping between the type parameters of a subtype to the corresponding type parameters of a supertype. For example, suppose we have the following classes:
And we pass HashMap and Map to mapTypeArguments, the result would be:class Map<M1,M2> class HashMap<H1, H2> extends Map<H1,H2>
Note, a single type argument in the subtype can map to multiple type parameters in the supertype. e.g.,Map(H1 => M1, H2 => M2)
would have the result:class OneTypeMap<O1> extends Map<O1,O1>
This utility only maps between corresponding type parameters, so the following class:Map(O1 => [M1,M2])
would have an empty map as a result:class StringMap extends Map<String,String>
Map() // there are no type argument relationships between the two types
-
-
Constructor Summary
Constructors Constructor Description TypeArgumentMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Set<org.plumelib.util.IPair<java.lang.Integer,java.lang.Integer>>
mapTypeArgumentIndices(javax.lang.model.element.TypeElement subtype, javax.lang.model.element.TypeElement supertype, javax.lang.model.util.Types types)
Returns a mapping from subtype's type parameter indices to the indices of corresponding type parameters in supertype.static java.util.Map<javax.lang.model.element.TypeParameterElement,java.util.Set<javax.lang.model.element.TypeParameterElement>>
mapTypeArguments(javax.lang.model.element.TypeElement subtype, javax.lang.model.element.TypeElement supertype, javax.lang.model.util.Types types)
Returns a mapping from the type parameters of subtype to a list of the type parameters in supertype that must be the same type as subtype.
-
-
-
Method Detail
-
mapTypeArgumentIndices
public static java.util.Set<org.plumelib.util.IPair<java.lang.Integer,java.lang.Integer>> mapTypeArgumentIndices(javax.lang.model.element.TypeElement subtype, javax.lang.model.element.TypeElement supertype, javax.lang.model.util.Types types)
Returns a mapping from subtype's type parameter indices to the indices of corresponding type parameters in supertype.
-
mapTypeArguments
public static java.util.Map<javax.lang.model.element.TypeParameterElement,java.util.Set<javax.lang.model.element.TypeParameterElement>> mapTypeArguments(javax.lang.model.element.TypeElement subtype, javax.lang.model.element.TypeElement supertype, javax.lang.model.util.Types types)
Returns a mapping from the type parameters of subtype to a list of the type parameters in supertype that must be the same type as subtype.e.g.,
results in aclass A<A1,A2,A3> class B<B1,B2,B3,B4> extends A<B1,B1,B3> {}
Map(B1 => [A1,A2], B2 => [], B3 => [A3], B4 => [])
- Returns:
- a mapping from the type parameters of subtype to the supertype type parameter's that to which they are a type argument
-
-