@@ -382,7 +382,7 @@ public TypeDescriptor getMapKeyTypeDescriptor() {
382
382
* @throws IllegalStateException if this type is not a java.util.Map.
383
383
* @see #narrow(Object)
384
384
*/
385
- public TypeDescriptor mapKeyTypeDescriptor (Object mapKey ) {
385
+ public TypeDescriptor getMapKeyTypeDescriptor (Object mapKey ) {
386
386
return narrow (mapKey , getMapKeyTypeDescriptor ());
387
387
}
388
388
@@ -407,55 +407,10 @@ public TypeDescriptor getMapValueTypeDescriptor() {
407
407
* @return the map value type descriptor
408
408
* @throws IllegalStateException if this type is not a java.util.Map.
409
409
*/
410
- public TypeDescriptor mapValueTypeDescriptor (Object mapValue ) {
410
+ public TypeDescriptor getMapValueTypeDescriptor (Object mapValue ) {
411
411
return narrow (mapValue , getMapValueTypeDescriptor ());
412
412
}
413
413
414
- // extending Object
415
-
416
- public boolean equals (Object obj ) {
417
- if (this == obj ) {
418
- return true ;
419
- }
420
- if (!(obj instanceof TypeDescriptor )) {
421
- return false ;
422
- }
423
- TypeDescriptor other = (TypeDescriptor ) obj ;
424
- boolean annotatedTypeEquals = ObjectUtils .nullSafeEquals (getType (), other .getType ()) && ObjectUtils .nullSafeEquals (getAnnotations (), other .getAnnotations ());
425
- if (!annotatedTypeEquals ) {
426
- return false ;
427
- }
428
- if (isCollection () || isArray ()) {
429
- return ObjectUtils .nullSafeEquals (getElementTypeDescriptor (), other .getElementTypeDescriptor ());
430
- }
431
- else if (isMap ()) {
432
- return ObjectUtils .nullSafeEquals (getMapKeyTypeDescriptor (), other .getMapKeyTypeDescriptor ()) && ObjectUtils .nullSafeEquals (getMapValueTypeDescriptor (), other .getMapValueTypeDescriptor ());
433
- }
434
- else {
435
- return true ;
436
- }
437
- }
438
-
439
- public int hashCode () {
440
- return getType ().hashCode ();
441
- }
442
-
443
- public String toString () {
444
- StringBuilder builder = new StringBuilder ();
445
- Annotation [] anns = getAnnotations ();
446
- for (Annotation ann : anns ) {
447
- builder .append ("@" ).append (ann .annotationType ().getName ()).append (' ' );
448
- }
449
- builder .append (ClassUtils .getQualifiedName (getType ()));
450
- if (isMap ()) {
451
- builder .append ("<" ).append (wildcard (getMapKeyTypeDescriptor ()));
452
- builder .append (", " ).append (wildcard (getMapValueTypeDescriptor ())).append (">" );
453
- }
454
- else if (isCollection ()) {
455
- builder .append ("<" ).append (wildcard (getElementTypeDescriptor ())).append (">" );
456
- }
457
- return builder .toString ();
458
- }
459
414
460
415
// deprecations in Spring 3.1
461
416
@@ -470,7 +425,7 @@ public Class<?> getElementType() {
470
425
}
471
426
472
427
/**
473
- * Returns the value of {@link TypeDescriptor#getType() getType()} for the {@link #getMapKeyTypeDescriptor() mapKeyTypeDescriptor }.
428
+ * Returns the value of {@link TypeDescriptor#getType() getType()} for the {@link #getMapKeyTypeDescriptor() getMapKeyTypeDescriptor }.
474
429
* @deprecated in Spring 3.1 in favor of {@link #getMapKeyTypeDescriptor()}.
475
430
* @throws IllegalStateException if this type is not a java.util.Map.
476
431
*/
@@ -480,7 +435,7 @@ public Class<?> getMapKeyType() {
480
435
}
481
436
482
437
/**
483
- * Returns the value of {@link TypeDescriptor#getType() getType()} for the {@link #getMapValueTypeDescriptor() mapValueTypeDescriptor }.
438
+ * Returns the value of {@link TypeDescriptor#getType() getType()} for the {@link #getMapValueTypeDescriptor() getMapValueTypeDescriptor }.
484
439
* @deprecated in Spring 3.1 in favor of {@link #getMapValueTypeDescriptor()}.
485
440
* @throws IllegalStateException if this type is not a java.util.Map.
486
441
*/
@@ -503,6 +458,7 @@ static Annotation[] nullSafeAnnotations(Annotation[] annotations) {
503
458
return annotations != null ? annotations : EMPTY_ANNOTATION_ARRAY ;
504
459
}
505
460
461
+
506
462
// internal constructors
507
463
508
464
private TypeDescriptor (Class <?> type ) {
@@ -536,6 +492,7 @@ private static TypeDescriptor nested(AbstractDescriptor descriptor, int nestingL
536
492
return new TypeDescriptor (descriptor );
537
493
}
538
494
495
+
539
496
// internal helpers
540
497
541
498
private void assertCollectionOrArray () {
@@ -570,4 +527,49 @@ private String wildcard(TypeDescriptor typeDescriptor) {
570
527
return typeDescriptor != null ? typeDescriptor .toString () : "?" ;
571
528
}
572
529
530
+
531
+ public boolean equals (Object obj ) {
532
+ if (this == obj ) {
533
+ return true ;
534
+ }
535
+ if (!(obj instanceof TypeDescriptor )) {
536
+ return false ;
537
+ }
538
+ TypeDescriptor other = (TypeDescriptor ) obj ;
539
+ boolean annotatedTypeEquals = ObjectUtils .nullSafeEquals (getType (), other .getType ()) && ObjectUtils .nullSafeEquals (getAnnotations (), other .getAnnotations ());
540
+ if (!annotatedTypeEquals ) {
541
+ return false ;
542
+ }
543
+ if (isCollection () || isArray ()) {
544
+ return ObjectUtils .nullSafeEquals (getElementTypeDescriptor (), other .getElementTypeDescriptor ());
545
+ }
546
+ else if (isMap ()) {
547
+ return ObjectUtils .nullSafeEquals (getMapKeyTypeDescriptor (), other .getMapKeyTypeDescriptor ()) && ObjectUtils .nullSafeEquals (getMapValueTypeDescriptor (), other .getMapValueTypeDescriptor ());
548
+ }
549
+ else {
550
+ return true ;
551
+ }
552
+ }
553
+
554
+ public int hashCode () {
555
+ return getType ().hashCode ();
556
+ }
557
+
558
+ public String toString () {
559
+ StringBuilder builder = new StringBuilder ();
560
+ Annotation [] anns = getAnnotations ();
561
+ for (Annotation ann : anns ) {
562
+ builder .append ("@" ).append (ann .annotationType ().getName ()).append (' ' );
563
+ }
564
+ builder .append (ClassUtils .getQualifiedName (getType ()));
565
+ if (isMap ()) {
566
+ builder .append ("<" ).append (wildcard (getMapKeyTypeDescriptor ()));
567
+ builder .append (", " ).append (wildcard (getMapValueTypeDescriptor ())).append (">" );
568
+ }
569
+ else if (isCollection ()) {
570
+ builder .append ("<" ).append (wildcard (getElementTypeDescriptor ())).append (">" );
571
+ }
572
+ return builder .toString ();
573
+ }
574
+
573
575
}
0 commit comments