当前位置: 首页>>代码示例>>Java>>正文


Java MethodParameter.getParameterAnnotation方法代码示例

本文整理汇总了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;

}
 
开发者ID:natsuforyou,项目名称:spring-boot-excel-plugin,代码行数:22,代码来源:ExcelRequestResponseBodyHandler.java

示例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));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:RequestParamMethodArgumentResolver.java

示例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));
    }
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:26,代码来源:WxApiParamContributor.java

示例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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:RequestParamMethodArgumentResolver.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:RequestParamMapMethodArgumentResolver.java

示例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);
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:14,代码来源:RequestParamArgumentResolver.java

示例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;
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:12,代码来源:BeanParamArgumentResolver.java

示例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);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:13,代码来源:WxApiPathContributor.java

示例9: createNamedValueInfo

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	Value annotation = parameter.getParameterAnnotation(Value.class);
	return new ExpressionValueNamedValueInfo(annotation);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:ExpressionValueMethodArgumentResolver.java

示例10: createNamedValueInfo

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	RequestHeader annotation = parameter.getParameterAnnotation(RequestHeader.class);
	return new RequestHeaderNamedValueInfo(annotation);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:RequestHeaderMethodArgumentResolver.java

示例11: createNamedValueInfo

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	CookieValue annotation = parameter.getParameterAnnotation(CookieValue.class);
	return new CookieValueNamedValueInfo(annotation);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:AbstractCookieValueMethodArgumentResolver.java

示例12: resolves

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
    return parameter.getParameterAnnotation(RequestParam.class) != null;
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:5,代码来源:RequestParamArgumentResolver.java

示例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;
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:6,代码来源:PathVariableArgumentResolver.java

示例14: resolves

import org.springframework.core.MethodParameter; //导入方法依赖的package包/类
@Override
public boolean resolves(MethodParameter parameter) {
    return parameter.getParameterAnnotation(BeanParam.class) != null;
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:5,代码来源:BeanParamArgumentResolver.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ModelFactory.java


注:本文中的org.springframework.core.MethodParameter.getParameterAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。