Skip to content

Commit 540213f

Browse files
committed
Improve javadocs as per #711
1 parent 2ea58d2 commit 540213f

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,25 @@ public JavaType uncheckedSimpleType(Class<?> cls) {
563563
/**
564564
* Factory method for constructing {@link JavaType} that
565565
* represents a parameterized type. For example, to represent
566-
* type <code>List&lt;Set&lt;Integer>></code>, you could
566+
* type <code>List&ltInteger></code>, you could
567567
* call
568568
*<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);
570577
*</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}.
571581
*<p>
572582
* 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+
*
575585
* @param parametrized Type-erased type of instance being constructed
576586
* @param parametersFor class or interface for which type parameters are applied; either
577587
* <code>parametrized</code> or one of its supertypes
@@ -604,13 +614,21 @@ public JavaType constructParametricType(Class<?> parametrized, Class<?>... param
604614
* type <code>List&lt;Set&lt;Integer>></code>, you could
605615
* call
606616
*<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);
609619
*</pre>
610620
*<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.
614632
*
615633
* @param parametrized Actual full type
616634
* @param parametersFor class or interface for which type parameters are applied; either

0 commit comments

Comments
 (0)