@@ -1228,6 +1228,20 @@ public static Class<?> erase(final Type type)
12281228 return GenericTypeReflector .erase (type );
12291229 }
12301230
1231+ /**
1232+ * See {@link TypeUtils#unrollVariables(Map, Type, boolean)}
1233+ *
1234+ * @param typeArguments
1235+ * @param type
1236+ * @param followTypeVars
1237+ * @return
1238+ */
1239+ public static Type unrollVariables (Map <TypeVariable <?>, Type > typeArguments ,
1240+ final Type type , boolean followTypeVars )
1241+ {
1242+ return TypeUtils .unrollVariables (typeArguments , type , followTypeVars );
1243+ }
1244+
12311245 // -- Helper methods --
12321246
12331247 private static IllegalArgumentException iae (final String ... s ) {
@@ -2802,13 +2816,36 @@ public static Type getArrayComponentType(final Type type) {
28022816 */
28032817 public static Type unrollVariables (Map <TypeVariable <?>, Type > typeArguments ,
28042818 final Type type )
2819+ {
2820+ return unrollVariables (typeArguments , type , true );
2821+ }
2822+
2823+ /**
2824+ * Get a type representing {@code type} with variable assignments
2825+ * "unrolled."
2826+ *
2827+ * @param typeArguments as from
2828+ * {@link TypeUtils#getTypeArguments(Type, Class)}
2829+ * @param type the type to unroll variable assignments for
2830+ * @param followTypeVars whether a {@link TypeVariable} should be recursively followed
2831+ * if it maps to another {@link TypeVariable}, or if it should be just replaced
2832+ * by the mapping
2833+ * @return Type
2834+ * @since 3.2
2835+ */
2836+ public static Type unrollVariables (Map <TypeVariable <?>, Type > typeArguments ,
2837+ final Type type , boolean followTypeVars )
28052838 {
28062839 if (typeArguments == null ) {
28072840 typeArguments = Collections .<TypeVariable <?>, Type > emptyMap ();
28082841 }
28092842 if (containsTypeVariables (type )) {
28102843 if (type instanceof TypeVariable ) {
2811- return unrollVariables (typeArguments , typeArguments .get (type ));
2844+ if (followTypeVars ) {
2845+ return unrollVariables (typeArguments , typeArguments .get (type ));
2846+ } else {
2847+ return typeArguments .get (type );
2848+ }
28122849 }
28132850 if (type instanceof ParameterizedType ) {
28142851 final ParameterizedType p = (ParameterizedType ) type ;
0 commit comments