本文整理汇总了Java中org.springframework.core.MethodParameter.getParameterIndex方法的典型用法代码示例。如果您正苦于以下问题:Java MethodParameter.getParameterIndex方法的具体用法?Java MethodParameter.getParameterIndex怎么用?Java MethodParameter.getParameterIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.MethodParameter
的用法示例。
在下文中一共展示了MethodParameter.getParameterIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DependencyDescriptor
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
/**
* Create a new descriptor for a method or constructor parameter.
* @param methodParameter the MethodParameter to wrap
* @param required whether the dependency is required
* @param eager whether this dependency is 'eager' in the sense of
* eagerly resolving potential target beans for type matching
*/
public DependencyDescriptor(MethodParameter methodParameter, boolean required, boolean eager) {
Assert.notNull(methodParameter, "MethodParameter must not be null");
this.methodParameter = methodParameter;
this.declaringClass = methodParameter.getDeclaringClass();
this.containingClass = methodParameter.getContainingClass();
if (this.methodParameter.getMethod() != null) {
this.methodName = methodParameter.getMethod().getName();
this.parameterTypes = methodParameter.getMethod().getParameterTypes();
}
else {
this.parameterTypes = methodParameter.getConstructor().getParameterTypes();
}
this.parameterIndex = methodParameter.getParameterIndex();
this.required = required;
this.eager = eager;
}
示例2: getObjectBody
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
private Object getObjectBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
MethodParameter methodParameter = wxApiMethodInfo.getMethodParameters().stream()
.filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiBody.class))
.findFirst().orElse(null);
if (methodParameter == null) {
throw new WxAppException("没有可处理的参数");
}
// 不是简单类型
if (!BeanUtils.isSimpleValueType(methodParameter.getParameterType())) {
// 暂时只支持json
return args[methodParameter.getParameterIndex()];
}
if (args[methodParameter.getParameterIndex()] != null) {
return args[methodParameter.getParameterIndex()].toString();
} else {
return "";
}
}
示例3: getStringBody
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
private String getStringBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
MethodParameter methodParameter = wxApiMethodInfo.getMethodParameters().stream()
.filter(p -> BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiBody.class))
.findFirst().orElse(null);
if (methodParameter == null) {
throw new WxAppException("没有可处理的参数");
}
// 不是简单类型
if (!BeanUtils.isSimpleValueType(methodParameter.getParameterType())) {
try {
// 暂时只支持json
return jsonConverter.writeValueAsString(args[methodParameter.getParameterIndex()]);
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if (args[methodParameter.getParameterIndex()] != null) {
return args[methodParameter.getParameterIndex()].toString();
} else {
return "";
}
}
示例4: isBindExceptionRequired
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
/**
* Whether to raise a {@link BindException} on validation errors.
* @param binder the data binder used to perform data binding
* @param parameter the method argument
* @return {@code true} if the next method argument is not of type {@link Errors}.
*/
protected boolean isBindExceptionRequired(WebDataBinder binder, MethodParameter parameter) {
int i = parameter.getParameterIndex();
Class<?>[] paramTypes = parameter.getMethod().getParameterTypes();
boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1]));
return !hasBindingResult;
}
示例5: handles
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean handles(MethodParameter parameter) {
if (parameter.getParameterIndex() != -1) {
throw new IllegalArgumentException(
"Method parameter must be a return value.");
}
Class<?> type = parameter.getParameterType();
return RestResponse.class.isAssignableFrom(type)
|| IRecordSet.class.isAssignableFrom(type)
|| type.getAnnotation(XmlRootElement.class) != null
|| IRecordSet.class.isAssignableFrom(type)
|| IJSONObject.class.isAssignableFrom(type)
|| IJSONArray.class.isAssignableFrom(type);
}