public class TypeArgumentMapper
extends java.lang.Object
class Map<M1,M2>
class HashMap<H1, H2> extends Map<H1,H2>
And we pass HashMap and Map to mapTypeArguments, the result would be:
Map(H1 ⇒ M1, H2 ⇒ M2)
Note, a single type argument in the subtype can map to multiple type parameters in the supertype.
e.g.,
class OneTypeMap<O1> extends Map<O1,O1>
would have the result:
Map(O1 ⇒ [M1,M2])
This utility only maps between corresponding type parameters, so the following class:
class StringMap extends Map<String,String>
would have an empty map as a result:
Map() // there are no type argument relationships between the two types
Constructor and Description |
---|
TypeArgumentMapper() |
Modifier and Type | Method and Description |
---|---|
static java.util.Set<Pair<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.
|
public static java.util.Set<Pair<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)
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)
e.g.,
class A<A1,A2,A3>
class B<B1,B2,B3,B4> extends A<B1,B1,B3> {}
results in a Map(B1 ⇒ [A1,A2], B2 ⇒ [], B3 ⇒ [A3], B4 ⇒ [])