diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/util/ClassTypeInformation.java b/spring-data-commons-core/src/main/java/org/springframework/data/util/ClassTypeInformation.java index e98685cde..c1047eb07 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/util/ClassTypeInformation.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/util/ClassTypeInformation.java @@ -15,6 +15,7 @@ */ package org.springframework.data.util; +import java.lang.reflect.Method; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.util.Map; @@ -40,6 +41,17 @@ public class ClassTypeInformation extends TypeDiscoverer { public static TypeInformation from(Class type) { return new ClassTypeInformation(type); } + + /** + * Creates a {@link TypeInformation} from the given method's return type. + * + * @param method + * @return + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static TypeInformation fromReturnTypeOf(Method method) { + return new ClassTypeInformation(method.getDeclaringClass()).createInfo(method.getGenericReturnType()); + } /** * Creates {@link ClassTypeInformation} for the given type.