diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeDiscoverer.java b/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeDiscoverer.java index aa95a2f61..7e0dfb2e6 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeDiscoverer.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeDiscoverer.java @@ -219,6 +219,19 @@ class TypeDiscoverer implements TypeInformation { public Class 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() diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeInformation.java b/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeInformation.java index 5af9e2f5c..bf1fc9138 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeInformation.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/util/TypeInformation.java @@ -64,4 +64,12 @@ public interface TypeInformation { * @return */ Class 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(); } \ No newline at end of file