You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: org.springframework.core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
+24-4Lines changed: 24 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -316,9 +316,15 @@ public TypeDescriptor getElementType() {
316
316
}
317
317
318
318
/**
319
-
* Creates a elementType descriptor from the provided collection or array element.
319
+
* If this type is a {@link Collection} or an Array, creates a elementType descriptor from the provided collection or array element.
320
+
* Narrows the {@link #getElementType() elementType} property to the class of the provided collection or array element.
321
+
* For example, if this describes a java.util.List<java.lang.Number< and the element argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer.
322
+
* If this describes a java.util.List<?> and the element argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer as well.
323
+
* Annotation and nested type context will be preserved in the narrowed TypeDescriptor that is returned.
320
324
* @param element the collection or array element
321
-
* @return the element type descriptor
325
+
* @return a element type descriptor, narrowed to the type of the provided element
326
+
* @throws IllegalStateException if this type is not a java.util.Collection or Array type
327
+
* @see #narrow(Object)
322
328
*/
323
329
publicTypeDescriptorelementType(Objectelement) {
324
330
assertCollectionOrArray();
@@ -350,9 +356,15 @@ public TypeDescriptor getMapKeyType() {
350
356
}
351
357
352
358
/**
353
-
* Creates a mapKeyType descriptor from the provided map key.
359
+
* If this type is a {@link Map}, creates a mapKeyType descriptor from the provided map key.
360
+
* Narrows the {@link #getMapKeyType() mapKeyType} property to the class of the provided map key.
361
+
* For example, if this describes a java.util.Map<java.lang.Number, java.lang.String< and the key argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer.
362
+
* If this describes a java.util.Map<?, ?> and the key argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer as well.
363
+
* Annotation and nested type context will be preserved in the narrowed TypeDescriptor that is returned.
354
364
* @param mapKey the map key
355
365
* @return the map key type descriptor
366
+
* @throws IllegalStateException if this type is not a java.util.Map.
367
+
* @see #narrow(Object)
356
368
*/
357
369
publicTypeDescriptormapKeyType(ObjectmapKey) {
358
370
assertMap();
@@ -375,9 +387,14 @@ public TypeDescriptor getMapValueType() {
375
387
}
376
388
377
389
/**
378
-
* Creates a mapValueType descriptor from the provided map value.
390
+
* If this type is a {@link Map}, creates a mapValueType descriptor from the provided map value.
391
+
* Narrows the {@link #getMapValueType() mapValueType} property to the class of the provided map value.
392
+
* For example, if this describes a java.util.Map<java.lang.String, java.lang.Number< and the value argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer.
393
+
* If this describes a java.util.Map<?, ?> and the value argument is a java.lang.Integer, the returned TypeDescriptor will be java.lang.Integer as well.
394
+
* Annotation and nested type context will be preserved in the narrowed TypeDescriptor that is returned.
379
395
* @param mapValue the map value
380
396
* @return the map value type descriptor
397
+
* @throws IllegalStateException if this type is not a java.util.Map.
0 commit comments