@@ -563,15 +563,25 @@ public JavaType uncheckedSimpleType(Class<?> cls) {
563
563
/**
564
564
* Factory method for constructing {@link JavaType} that
565
565
* represents a parameterized type. For example, to represent
566
- * type <code>List<Set<Integer> ></code>, you could
566
+ * type <code>List<Integer ></code>, you could
567
567
* call
568
568
*<pre>
569
- * TypeFactory.parametricType(List.class, Integer.class);
569
+ * TypeFactory.constructParametrizedType(List.class, List.class, Integer.class);
570
+ *</pre>
571
+ *<p>
572
+ * The reason for first two arguments to be separate is that parameterization may
573
+ * apply to a super-type. For example, if generic type was instead to be
574
+ * constructed for <code>ArrayList<Integer></code>, the usual call would be:
575
+ *<pre>
576
+ * TypeFactory.constructParametrizedType(ArrayList.class, List.class, Integer.class);
570
577
*</pre>
578
+ * since parameterization is applied to {@link java.util.List}.
579
+ * In most cases distinction does not matter, but there are types where it does;
580
+ * one such example is parameterization of types that implement {@link java.util.Iterator}.
571
581
*<p>
572
582
* NOTE: type modifiers are NOT called on constructed type itself; but are called
573
- * for contained types .
574
- *
583
+ * when resolving <code>parameterClasses</code> into {@link JavaType} .
584
+ *
575
585
* @param parametrized Type-erased type of instance being constructed
576
586
* @param parametersFor class or interface for which type parameters are applied; either
577
587
* <code>parametrized</code> or one of its supertypes
@@ -604,13 +614,21 @@ public JavaType constructParametricType(Class<?> parametrized, Class<?>... param
604
614
* type <code>List<Set<Integer>></code>, you could
605
615
* call
606
616
*<pre>
607
- * JavaType inner = TypeFactory.parametricType( Set.class, Integer.class);
608
- * TypeFactory.parametricType( List.class, inner);
617
+ * JavaType inner = TypeFactory.constructParametrizedType(Set.class, Set.class, Integer.class);
618
+ * return TypeFactory.constructParametrizedType(ArrayList.class, List.class, inner);
609
619
*</pre>
610
620
*<p>
611
- * NOTE: type modifiers are NOT called on constructed type itself; but are called
612
- * for contained types.
613
- *
621
+ * The reason for first two arguments to be separate is that parameterization may
622
+ * apply to a super-type. For example, if generic type was instead to be
623
+ * constructed for <code>ArrayList<Integer></code>, the usual call would be:
624
+ *<pre>
625
+ * TypeFactory.constructParametrizedType(ArrayList.class, List.class, Integer.class);
626
+ *</pre>
627
+ * since parameterization is applied to {@link java.util.List}.
628
+ * In most cases distinction does not matter, but there are types where it does;
629
+ * one such example is parameterization of types that implement {@link java.util.Iterator}.
630
+ *<p>
631
+ * NOTE: type modifiers are NOT called on constructed type.
614
632
*
615
633
* @param parametrized Actual full type
616
634
* @param parametersFor class or interface for which type parameters are applied; either
0 commit comments