Skip to content

Commit 1cea52b

Browse files
committed
renamed mapKey/ValueTypeDescriptor methods back to getMapKey/ValueTypeDescriptor (for Spring 3.0.x compatibility)
1 parent ba2c8fc commit 1cea52b

File tree

4 files changed

+58
-56
lines changed

4 files changed

+58
-56
lines changed

org.springframework.core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public TypeDescriptor getMapKeyTypeDescriptor() {
382382
* @throws IllegalStateException if this type is not a java.util.Map.
383383
* @see #narrow(Object)
384384
*/
385-
public TypeDescriptor mapKeyTypeDescriptor(Object mapKey) {
385+
public TypeDescriptor getMapKeyTypeDescriptor(Object mapKey) {
386386
return narrow(mapKey, getMapKeyTypeDescriptor());
387387
}
388388

@@ -407,55 +407,10 @@ public TypeDescriptor getMapValueTypeDescriptor() {
407407
* @return the map value type descriptor
408408
* @throws IllegalStateException if this type is not a java.util.Map.
409409
*/
410-
public TypeDescriptor mapValueTypeDescriptor(Object mapValue) {
410+
public TypeDescriptor getMapValueTypeDescriptor(Object mapValue) {
411411
return narrow(mapValue, getMapValueTypeDescriptor());
412412
}
413413

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-
}
459414

460415
// deprecations in Spring 3.1
461416

@@ -470,7 +425,7 @@ public Class<?> getElementType() {
470425
}
471426

472427
/**
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}.
474429
* @deprecated in Spring 3.1 in favor of {@link #getMapKeyTypeDescriptor()}.
475430
* @throws IllegalStateException if this type is not a java.util.Map.
476431
*/
@@ -480,7 +435,7 @@ public Class<?> getMapKeyType() {
480435
}
481436

482437
/**
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}.
484439
* @deprecated in Spring 3.1 in favor of {@link #getMapValueTypeDescriptor()}.
485440
* @throws IllegalStateException if this type is not a java.util.Map.
486441
*/
@@ -503,6 +458,7 @@ static Annotation[] nullSafeAnnotations(Annotation[] annotations) {
503458
return annotations != null ? annotations : EMPTY_ANNOTATION_ARRAY;
504459
}
505460

461+
506462
// internal constructors
507463

508464
private TypeDescriptor(Class<?> type) {
@@ -536,6 +492,7 @@ private static TypeDescriptor nested(AbstractDescriptor descriptor, int nestingL
536492
return new TypeDescriptor(descriptor);
537493
}
538494

495+
539496
// internal helpers
540497

541498
private void assertCollectionOrArray() {
@@ -570,4 +527,49 @@ private String wildcard(TypeDescriptor typeDescriptor) {
570527
return typeDescriptor != null ? typeDescriptor.toString() : "?";
571528
}
572529

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+
573575
}

org.springframework.core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ private Object convertKey(Object sourceKey, TypeDescriptor sourceType, TypeDescr
8787
if (targetType == null) {
8888
return sourceKey;
8989
}
90-
return this.conversionService.convert(sourceKey, sourceType.mapKeyTypeDescriptor(sourceKey), targetType);
90+
return this.conversionService.convert(sourceKey, sourceType.getMapKeyTypeDescriptor(sourceKey), targetType);
9191
}
9292

9393
private Object convertValue(Object sourceValue, TypeDescriptor sourceType, TypeDescriptor targetType) {
9494
if (targetType == null) {
9595
return sourceValue;
9696
}
97-
return this.conversionService.convert(sourceValue, sourceType.mapValueTypeDescriptor(sourceValue), targetType);
97+
return this.conversionService.convert(sourceValue, sourceType.getMapValueTypeDescriptor(sourceValue), targetType);
9898
}
9999

100100
}

org.springframework.core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public void elementTypePreserveContext() throws Exception {
706706
public void mapKeyType() {
707707
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
708708
Integer value = new Integer(3);
709-
desc = desc.mapKeyTypeDescriptor(value);
709+
desc = desc.getMapKeyTypeDescriptor(value);
710710
assertEquals(Integer.class, desc.getType());
711711
}
712712

@@ -715,7 +715,7 @@ public void mapKeyTypePreserveContext() throws Exception {
715715
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
716716
assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType());
717717
List<Integer> value = new ArrayList<Integer>(3);
718-
desc = desc.mapKeyTypeDescriptor(value);
718+
desc = desc.getMapKeyTypeDescriptor(value);
719719
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
720720
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
721721
}
@@ -727,7 +727,7 @@ public void mapKeyTypePreserveContext() throws Exception {
727727
public void mapValueType() {
728728
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
729729
Integer value = new Integer(3);
730-
desc = desc.mapValueTypeDescriptor(value);
730+
desc = desc.getMapValueTypeDescriptor(value);
731731
assertEquals(Integer.class, desc.getType());
732732
}
733733

@@ -736,7 +736,7 @@ public void mapValueTypePreserveContext() throws Exception {
736736
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
737737
assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
738738
List<Integer> value = new ArrayList<Integer>(3);
739-
desc = desc.mapValueTypeDescriptor(value);
739+
desc = desc.getMapValueTypeDescriptor(value);
740740
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
741741
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
742742
}

org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep
9595
key = state.convertValue(key, targetObjectTypeDescriptor.getMapKeyTypeDescriptor());
9696
}
9797
Object value = ((Map<?, ?>) targetObject).get(key);
98-
return new TypedValue(value, targetObjectTypeDescriptor.mapValueTypeDescriptor(value));
98+
return new TypedValue(value, targetObjectTypeDescriptor.getMapValueTypeDescriptor(value));
9999
}
100100

101101
if (targetObject == null) {

0 commit comments

Comments
 (0)