DATACMNS-63 - Added fromReturnTypeOf(…) to ClassTypeInformation.

This commit is contained in:
Oliver Gierke
2011-08-21 16:30:20 +02:00
parent 5cfd8bc3df
commit e21dd1d828

View File

@@ -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<S> extends TypeDiscoverer<S> {
public static <S> TypeInformation<S> from(Class<S> type) {
return new ClassTypeInformation<S>(type);
}
/**
* Creates a {@link TypeInformation} from the given method's return type.
*
* @param method
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <S> TypeInformation<S> fromReturnTypeOf(Method method) {
return new ClassTypeInformation(method.getDeclaringClass()).createInfo(method.getGenericReturnType());
}
/**
* Creates {@link ClassTypeInformation} for the given type.