@ -382,7 +382,7 @@ public class TypeDescriptor {
@@ -382,7 +382,7 @@ public class TypeDescriptor {
* @throws IllegalStateException if this type is not a java . util . Map .
* @see # narrow ( Object )
* /
public TypeDescriptor m apKeyTypeDescriptor( Object mapKey ) {
public TypeDescriptor getM apKeyTypeDescriptor( Object mapKey ) {
return narrow ( mapKey , getMapKeyTypeDescriptor ( ) ) ;
}
@ -407,55 +407,10 @@ public class TypeDescriptor {
@@ -407,55 +407,10 @@ public class TypeDescriptor {
* @return the map value type descriptor
* @throws IllegalStateException if this type is not a java . util . Map .
* /
public TypeDescriptor m apValueTypeDescriptor( Object mapValue ) {
public TypeDescriptor getM apValueTypeDescriptor( Object mapValue ) {
return narrow ( mapValue , getMapValueTypeDescriptor ( ) ) ;
}
// extending Object
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof TypeDescriptor ) ) {
return false ;
}
TypeDescriptor other = ( TypeDescriptor ) obj ;
boolean annotatedTypeEquals = ObjectUtils . nullSafeEquals ( getType ( ) , other . getType ( ) ) & & ObjectUtils . nullSafeEquals ( getAnnotations ( ) , other . getAnnotations ( ) ) ;
if ( ! annotatedTypeEquals ) {
return false ;
}
if ( isCollection ( ) | | isArray ( ) ) {
return ObjectUtils . nullSafeEquals ( getElementTypeDescriptor ( ) , other . getElementTypeDescriptor ( ) ) ;
}
else if ( isMap ( ) ) {
return ObjectUtils . nullSafeEquals ( getMapKeyTypeDescriptor ( ) , other . getMapKeyTypeDescriptor ( ) ) & & ObjectUtils . nullSafeEquals ( getMapValueTypeDescriptor ( ) , other . getMapValueTypeDescriptor ( ) ) ;
}
else {
return true ;
}
}
public int hashCode ( ) {
return getType ( ) . hashCode ( ) ;
}
public String toString ( ) {
StringBuilder builder = new StringBuilder ( ) ;
Annotation [ ] anns = getAnnotations ( ) ;
for ( Annotation ann : anns ) {
builder . append ( "@" ) . append ( ann . annotationType ( ) . getName ( ) ) . append ( ' ' ) ;
}
builder . append ( ClassUtils . getQualifiedName ( getType ( ) ) ) ;
if ( isMap ( ) ) {
builder . append ( "<" ) . append ( wildcard ( getMapKeyTypeDescriptor ( ) ) ) ;
builder . append ( ", " ) . append ( wildcard ( getMapValueTypeDescriptor ( ) ) ) . append ( ">" ) ;
}
else if ( isCollection ( ) ) {
builder . append ( "<" ) . append ( wildcard ( getElementTypeDescriptor ( ) ) ) . append ( ">" ) ;
}
return builder . toString ( ) ;
}
// deprecations in Spring 3.1
@ -470,7 +425,7 @@ public class TypeDescriptor {
@@ -470,7 +425,7 @@ public class TypeDescriptor {
}
/ * *
* Returns the value of { @link TypeDescriptor # getType ( ) getType ( ) } for the { @link # getMapKeyTypeDescriptor ( ) m apKeyTypeDescriptor} .
* Returns the value of { @link TypeDescriptor # getType ( ) getType ( ) } for the { @link # getMapKeyTypeDescriptor ( ) getM apKeyTypeDescriptor} .
* @deprecated in Spring 3 . 1 in favor of { @link # getMapKeyTypeDescriptor ( ) } .
* @throws IllegalStateException if this type is not a java . util . Map .
* /
@ -480,7 +435,7 @@ public class TypeDescriptor {
@@ -480,7 +435,7 @@ public class TypeDescriptor {
}
/ * *
* Returns the value of { @link TypeDescriptor # getType ( ) getType ( ) } for the { @link # getMapValueTypeDescriptor ( ) m apValueTypeDescriptor} .
* Returns the value of { @link TypeDescriptor # getType ( ) getType ( ) } for the { @link # getMapValueTypeDescriptor ( ) getM apValueTypeDescriptor} .
* @deprecated in Spring 3 . 1 in favor of { @link # getMapValueTypeDescriptor ( ) } .
* @throws IllegalStateException if this type is not a java . util . Map .
* /
@ -503,6 +458,7 @@ public class TypeDescriptor {
@@ -503,6 +458,7 @@ public class TypeDescriptor {
return annotations ! = null ? annotations : EMPTY_ANNOTATION_ARRAY ;
}
// internal constructors
private TypeDescriptor ( Class < ? > type ) {
@ -536,6 +492,7 @@ public class TypeDescriptor {
@@ -536,6 +492,7 @@ public class TypeDescriptor {
return new TypeDescriptor ( descriptor ) ;
}
// internal helpers
private void assertCollectionOrArray ( ) {
@ -570,4 +527,49 @@ public class TypeDescriptor {
@@ -570,4 +527,49 @@ public class TypeDescriptor {
return typeDescriptor ! = null ? typeDescriptor . toString ( ) : "?" ;
}
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof TypeDescriptor ) ) {
return false ;
}
TypeDescriptor other = ( TypeDescriptor ) obj ;
boolean annotatedTypeEquals = ObjectUtils . nullSafeEquals ( getType ( ) , other . getType ( ) ) & & ObjectUtils . nullSafeEquals ( getAnnotations ( ) , other . getAnnotations ( ) ) ;
if ( ! annotatedTypeEquals ) {
return false ;
}
if ( isCollection ( ) | | isArray ( ) ) {
return ObjectUtils . nullSafeEquals ( getElementTypeDescriptor ( ) , other . getElementTypeDescriptor ( ) ) ;
}
else if ( isMap ( ) ) {
return ObjectUtils . nullSafeEquals ( getMapKeyTypeDescriptor ( ) , other . getMapKeyTypeDescriptor ( ) ) & & ObjectUtils . nullSafeEquals ( getMapValueTypeDescriptor ( ) , other . getMapValueTypeDescriptor ( ) ) ;
}
else {
return true ;
}
}
public int hashCode ( ) {
return getType ( ) . hashCode ( ) ;
}
public String toString ( ) {
StringBuilder builder = new StringBuilder ( ) ;
Annotation [ ] anns = getAnnotations ( ) ;
for ( Annotation ann : anns ) {
builder . append ( "@" ) . append ( ann . annotationType ( ) . getName ( ) ) . append ( ' ' ) ;
}
builder . append ( ClassUtils . getQualifiedName ( getType ( ) ) ) ;
if ( isMap ( ) ) {
builder . append ( "<" ) . append ( wildcard ( getMapKeyTypeDescriptor ( ) ) ) ;
builder . append ( ", " ) . append ( wildcard ( getMapValueTypeDescriptor ( ) ) ) . append ( ">" ) ;
}
else if ( isCollection ( ) ) {
builder . append ( "<" ) . append ( wildcard ( getElementTypeDescriptor ( ) ) ) . append ( ">" ) ;
}
return builder . toString ( ) ;
}
}