Added TypeInformation.getActualType().

The method transparently resolves the property type, collection component type or map value type depending on what the core type is.
This commit is contained in:
Oliver Gierke
2011-06-17 19:40:27 +02:00
parent e86721fbdb
commit 3addb9c2f8
2 changed files with 21 additions and 0 deletions

View File

@@ -219,6 +219,19 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
public Class<S> getType() {
return resolveType(type);
}
/* (non-Javadoc)
* @see org.springframework.data.util.TypeInformation#getActualType()
*/
public TypeInformation<?> getActualType() {
if (isMap()) {
return getMapValueType();
} else if (isCollectionLike()) {
return getComponentType();
} else {
return this;
}
}
/* (non-Javadoc)
* @see org.springframework.data.util.TypeInformation#isMap()

View File

@@ -64,4 +64,12 @@ public interface TypeInformation<S> {
* @return
*/
Class<S> getType();
/**
* Transparently returns the {@link Map} value type if the type is a {@link Map}, returns the component type if the
* type {@link #isCollectionLike()} or the simple type if none of this applies.
*
* @return
*/
TypeInformation<?> getActualType();
}