當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。