本文整理汇总了Java中org.springframework.core.MethodParameter.getParameterAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java MethodParameter.getParameterAnnotation方法的具体用法?Java MethodParameter.getParameterAnnotation怎么用?Java MethodParameter.getParameterAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.MethodParameter
的用法示例。
在下文中一共展示了MethodParameter.getParameterAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(servletRequest, MultipartHttpServletRequest.class);
ExcelRequestBody annotation = parameter.getParameterAnnotation(ExcelRequestBody.class);
if (multipartRequest != null) {
List<Object> result = new ArrayList<>();
List<MultipartFile> files = multipartRequest.getFiles(annotation.name());
for (MultipartFile file : files) {
if (converters.supportsExcelType(annotation.type())) {
List<?> part = converters.fromExcel(annotation, file.getInputStream());
result.addAll(part);
}
}
return result;
}
return null;
}
示例2: contributeMethodArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public void contributeMethodArgument(MethodParameter parameter, Object value,
UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
Class<?> paramType = parameter.getParameterType();
if (Map.class.isAssignableFrom(paramType) || MultipartFile.class.equals(paramType) ||
"javax.servlet.http.Part".equals(paramType.getName())) {
return;
}
RequestParam annot = parameter.getParameterAnnotation(RequestParam.class);
String name = StringUtils.isEmpty(annot.value()) ? parameter.getParameterName() : annot.value();
if (value == null) {
builder.queryParam(name);
}
else if (value instanceof Collection) {
for (Object element : (Collection<?>) value) {
element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
builder.queryParam(name, element);
}
}
else {
builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
}
}
示例3: contributeMethodArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public void contributeMethodArgument(MethodParameter parameter, Object value, UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
Class<?> paramType = parameter.getNestedParameterType();
if (Map.class.isAssignableFrom(paramType)) {
return;
}
WxApiParam wxApiParam = parameter.getParameterAnnotation(WxApiParam.class);
String name = (wxApiParam == null || StringUtils.isEmpty(wxApiParam.name()) ? parameter.getParameterName() : wxApiParam.name());
WxAppAssert.notNull(name, "请添加编译器的-parameter或者为参数添加注解名称");
if (value == null) {
if (wxApiParam != null) {
if (!wxApiParam.required() || !wxApiParam.defaultValue().equals(ValueConstants.DEFAULT_NONE)) {
return;
}
}
builder.queryParam(name);
} else if (value instanceof Collection) {
for (Object element : (Collection<?>) value) {
element = formatUriValue(conversionService, TypeDescriptor.nested(parameter, 1), element);
builder.queryParam(name, element);
}
} else {
builder.queryParam(name, formatUriValue(conversionService, new TypeDescriptor(parameter), value));
}
}
示例4: createNamedValueInfo
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestParam annotation = parameter.getParameterAnnotation(RequestParam.class);
return (annotation != null) ?
new RequestParamNamedValueInfo(annotation) :
new RequestParamNamedValueInfo();
}
示例5: supportsParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean supportsParameter(MethodParameter parameter) {
RequestParam requestParamAnnot = parameter.getParameterAnnotation(RequestParam.class);
if (requestParamAnnot != null) {
if (Map.class.isAssignableFrom(parameter.getParameterType())) {
return !StringUtils.hasText(requestParamAnnot.value());
}
}
return false;
}
示例6: resolveArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter,
RestRequest request, RestDelegate handler) throws Exception {
Class<?> type = parameter.getParameterType();
RequestParam annotation = parameter
.getParameterAnnotation(RequestParam.class);
String value = annotation.value();
JSONObject operationInput = new JSONObject(request.getOperationInput());
Object param = operationInput.opt(value);
return objectMapper.readValue(param != null ? param.toString() : null,
type);
}
示例7: resolveArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter,
RestRequest request, RestDelegate handler) throws Exception {
Class<?> type = parameter.getParameterType();
BeanParam annotation = parameter
.getParameterAnnotation(BeanParam.class);
if (annotation != null) {
return objectMapper.readValue(request.getOperationInput(), type);
}
return null;
}
示例8: contributeMethodArgument
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public void contributeMethodArgument(MethodParameter parameter, Object value,
UriComponentsBuilder builder, Map<String, Object> uriVariables, ConversionService conversionService) {
if (Map.class.isAssignableFrom(parameter.nestedIfOptional().getNestedParameterType())) {
return;
}
WxApiPath wx = parameter.getParameterAnnotation(WxApiPath.class);
String name = (wx != null && !StringUtils.isEmpty(wx.value()) ? wx.value() : parameter.getParameterName());
WxAppAssert.notNull(name, "请添加编译器的-parameter或者为参数添加注解名称");
value = formatUriValue(conversionService, new TypeDescriptor(parameter.nestedIfOptional()), value);
uriVariables.put(name, value);
}
示例9: createNamedValueInfo
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
Value annotation = parameter.getParameterAnnotation(Value.class);
return new ExpressionValueNamedValueInfo(annotation);
}
示例10: createNamedValueInfo
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
RequestHeader annotation = parameter.getParameterAnnotation(RequestHeader.class);
return new RequestHeaderNamedValueInfo(annotation);
}
示例11: createNamedValueInfo
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
CookieValue annotation = parameter.getParameterAnnotation(CookieValue.class);
return new CookieValueNamedValueInfo(annotation);
}
示例12: resolves
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
return parameter.getParameterAnnotation(RequestParam.class) != null;
}
示例13: resolves
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
return parameter.getMethodAnnotation(RequestMapping.class) != null
&& parameter.getParameterAnnotation(PathVariable.class) != null;
}
示例14: resolves
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
return parameter.getParameterAnnotation(BeanParam.class) != null;
}
示例15: getNameForParameter
import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
/**
* Derives the model attribute name for a method parameter based on:
* <ol>
* <li>The parameter {@code @ModelAttribute} annotation value
* <li>The parameter type
* </ol>
* @return the derived name; never {@code null} or an empty string
*/
public static String getNameForParameter(MethodParameter parameter) {
ModelAttribute annot = parameter.getParameterAnnotation(ModelAttribute.class);
String attrName = (annot != null) ? annot.value() : null;
return StringUtils.hasText(attrName) ? attrName : Conventions.getVariableNameForParameter(parameter);
}