Example usage for org.springframework.core MethodParameter getConstructor

List of usage examples for org.springframework.core MethodParameter getConstructor

Introduction

In this page you can find the example usage for org.springframework.core MethodParameter getConstructor.

Prototype

@Nullable
public Constructor<?> getConstructor() 

Source Link

Document

Return the wrapped Constructor, if any.

Usage

From source file:org.springframework.core.GenericTypeResolver.java

/**
 * Determine the target type for the given parameter specification.
 * @param methodParam the method parameter specification
 * @return the corresponding generic parameter type
 *//*w w  w. j  av  a  2s .c o m*/
public static Type getTargetType(MethodParameter methodParam) {
    Assert.notNull(methodParam, "MethodParameter must not be null");
    if (methodParam.getConstructor() != null) {
        return methodParam.getConstructor().getGenericParameterTypes()[methodParam.getParameterIndex()];
    } else {
        if (methodParam.getParameterIndex() >= 0) {
            return methodParam.getMethod().getGenericParameterTypes()[methodParam.getParameterIndex()];
        } else {
            return methodParam.getMethod().getGenericReturnType();
        }
    }
}