• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ValueConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.bind.annotation.ValueConstants的典型用法代码示例。如果您正苦于以下问题:Java ValueConstants类的具体用法?Java ValueConstants怎么用?Java ValueConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValueConstants类属于org.springframework.web.bind.annotation包,在下文中一共展示了ValueConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: contributeMethodArgument

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的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


示例2: updateNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.length() == 0) {
		name = parameter.getParameterName();
		Assert.notNull(name, "Name for argument type [" + parameter.getParameterType().getName()
					+ "] not available, and parameter name information not found in class file either.");
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AbstractNamedValueMethodArgumentResolver.java


示例3: RequestParamResolveBean

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
public RequestParamResolveBean(Class<?> clazz, String paraName, boolean required, String defaultValue, DataConverter dataConverter) {
    this.clazz = clazz;
    this.paraName = paraName;
    this.required = required;
    if (ValueConstants.DEFAULT_NONE.equals(defaultValue)) {
        this.defaultValue = dataConverter.defaultValue();
    } else if (StringUtils.isNotEmpty(defaultValue)) {
        this.defaultValue = dataConverter.toObject(defaultValue);
    } else {
        this.defaultValue = dataConverter.defaultValue();
    }
    this.dataConverter = dataConverter;
    this.isReference = dataConverter instanceof ReferenceDataConverter;
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:15,代码来源:RequestParamResolveBean.java


示例4: getMethodWxApiRequestPath

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
private String getMethodWxApiRequestPath(Method method) {
    WxApiRequest wxApiRequest = AnnotatedElementUtils.findMergedAnnotation(method, WxApiRequest.class);
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.path()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.path())) {
        // 默认情况下取方法名为变量名,尝试从环境变量中获取信息
        return WxContextUtils.resolveStringValue("${" + this.wxApiTypeInfo.getPropertyPrefix() + "." + method.getName() + "}");
    }
    return wxApiRequest.path();
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:9,代码来源:WxApiMethodInfo.java


示例5: getFormBody

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
/**
 * 要发送文件,使用这种方式,请查看源码:FormHttpMessageConverter
 *
 * @param wxApiMethodInfo
 * @param args
 * @return dummy
 */
private Object getFormBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    wxApiMethodInfo.getMethodParameters().stream()
            .filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiForm.class) || p.hasParameterAnnotation(WxApiBody.class))
            .forEach(p -> {
                // 为空则直接返回不加这个参数
                if (args[p.getParameterIndex()] == null) {
                    return;
                }
                WxApiForm wxApiForm = p.getParameterAnnotation(WxApiForm.class);
                String paramName;
                Object param;
                if (wxApiForm == null || ValueConstants.DEFAULT_NONE.equals(wxApiForm.value())) {
                    paramName = p.getParameterName();
                } else {
                    paramName = wxApiForm.value();
                }
                // 加入Assert
                WxAppAssert.notNull(paramName, "请添加编译器的-parameter或者为参数添加注解名称");
                if (WxWebUtils.isMutlipart(p.getParameterType())) {
                    param = getFormResource(args[p.getParameterIndex()]);
                } else {
                    param = args[p.getParameterIndex()];
                }
                params.add(paramName, param);
            });
    return params;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:36,代码来源:WxApiExecutor.java


示例6: updateNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
/**
 * Create a new NamedValueInfo based on the given NamedValueInfo with sanitized values.
 */
private NamedValueInfo updateNamedValueInfo(MethodParameter parameter, NamedValueInfo info) {
	String name = info.name;
	if (info.name.length() == 0) {
		name = parameter.getParameterName();
		if (name == null) {
			throw new IllegalArgumentException("Name for argument type [" + parameter.getParameterType().getName() +
					"] not available, and parameter name information not found in class file either.");
		}
	}
	String defaultValue = (ValueConstants.DEFAULT_NONE.equals(info.defaultValue) ? null : info.defaultValue);
	return new NamedValueInfo(name, info.required, defaultValue);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AbstractNamedValueMethodArgumentResolver.java


示例7: updatePathRequestProperties

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
/**
 * Update the contextPath, servletPath, and pathInfo of the request.
 */
private void updatePathRequestProperties(MockHttpServletRequest request, String requestUri) {
	Assert.isTrue(requestUri.startsWith(this.contextPath),
			"requestURI [" + requestUri + "] does not start with contextPath [" + this.contextPath + "]");
	request.setContextPath(this.contextPath);
	request.setServletPath(this.servletPath);
	if (ValueConstants.DEFAULT_NONE.equals(this.pathInfo)) {
		Assert.isTrue(requestUri.startsWith(this.contextPath + this.servletPath),
				"Invalid servletPath [" + this.servletPath + "] for requestURI [" + requestUri + "]");
		String extraPath = requestUri.substring(this.contextPath.length() + this.servletPath.length());
		this.pathInfo = (StringUtils.hasText(extraPath)) ? extraPath : null;
	}
	request.setPathInfo(this.pathInfo);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:MockHttpServletRequestBuilder.java


示例8: handleArg

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
protected void handleArg(MultiValueMap<String, Object> values, ApiClientMethodParameter mp, final Object pvalue, boolean flatable){
		Object paramValue = pvalue;
		if(mp.hasParameterAnnotation(RequestParam.class)){
			RequestParam params = mp.getParameterAnnotation(RequestParam.class);
			if(pvalue==null && params.required() && (paramValue=params.defaultValue())==ValueConstants.DEFAULT_NONE){
				throw new BaseException("parameter["+params.name()+"] must be required : " + mp.getParameterName());
			}
		}
		
		if(flatable){
			beanToMapConvertor.flatObject(mp.getParameterName(), paramValue, (k, v, ctx)->{
				if(v instanceof Enum){
					Enum<?> e = (Enum<?>)v;
					if(e instanceof ValueEnum){
						v = ((ValueEnum<?>)e).getValue();
					}else{//默认使用name
						v = e.name();
					}
				}
				if(ctx!=null){
//					System.out.println("ctx.getName():"+ctx.getName());
					values.add(ctx.getName(), v.toString());
				}else{
					values.add(k, v.toString());
				}
	//			values.put(k, v);
			});
		}else{
			values.add(mp.getParameterName(), pvalue);
		}
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:32,代码来源:ApiClientMethod.java


示例9: build

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
@Override
public Param build(Method javaMethod, int paramIndex, Annotation paramAnnotation) {
    final RequestParam requestParam = (RequestParam) paramAnnotation;
    final Param param = new Param()
            .withName(discoverParamName(javaMethod, paramIndex, requestParam.value()))
            .withStyle(ParamStyle.QUERY)
            .withRequired(requestParam.required())
            .withType(grammarsDiscoverer.discoverQNameFor(new ClassMetadataFromParam(javaMethod, paramIndex)));

    if (!ValueConstants.DEFAULT_NONE.equals(requestParam.defaultValue())) {
        param.setDefault(requestParam.defaultValue());
    }
    return param;
}
 
开发者ID:autentia,项目名称:wadl-tools,代码行数:15,代码来源:ParamFromRequestParamBuilder.java


示例10: RequestParamNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
public RequestParamNamedValueInfo() {
	super("", false, ValueConstants.DEFAULT_NONE);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:RequestParamMethodArgumentResolver.java


示例11: parseDefaultValueAttribute

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
protected String parseDefaultValueAttribute(String value) {
	return (ValueConstants.DEFAULT_NONE.equals(value) ? null : value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:HandlerMethodInvoker.java


示例12: RequestParamNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
public RequestParamNamedValueInfo() {
    super("", false, ValueConstants.DEFAULT_NONE);
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:4,代码来源:WxArgumentResolver.java


示例13: getTypeWxApiHost

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
private String getTypeWxApiHost(WxApiRequest wxApiRequest, String defaultHost) {
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.host()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.host())) {
        return defaultHost;
    }
    return wxApiRequest.host();
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:7,代码来源:WxApiTypeInfo.java


示例14: getTypeWxApiPropertyPrefix

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
private String getTypeWxApiPropertyPrefix(WxApiRequest wxApiRequest) {
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.prefix()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.prefix())) {
        return WX_API_PROPERTY_PREFIX;
    }
    return wxApiRequest.prefix();
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:7,代码来源:WxApiTypeInfo.java


示例15: getTypeWxApiRequestPath

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
private String getTypeWxApiRequestPath(WxApiRequest wxApiRequest) {
    if (wxApiRequest == null || StringUtils.isEmpty(wxApiRequest.path()) || ValueConstants.DEFAULT_NONE.equals(wxApiRequest.path())) {
        return "/";
    }
    return wxApiRequest.path();
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:7,代码来源:WxApiTypeInfo.java


示例16: resolveName

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
@Override
protected Object resolveName(String name, MethodParameter parameter, NativeWebRequest request) throws Exception {

	@SuppressWarnings("unchecked")
	Map<String, MultiValueMap<String, String>> pathParameters =
		(Map<String, MultiValueMap<String, String>>) request.getAttribute(
				HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);

	if (CollectionUtils.isEmpty(pathParameters)) {
		return null;
	}

	String pathVar = parameter.getParameterAnnotation(MatrixVariable.class).pathVar();
	List<String> paramValues = null;

	if (!pathVar.equals(ValueConstants.DEFAULT_NONE)) {
		if (pathParameters.containsKey(pathVar)) {
			paramValues = pathParameters.get(pathVar).get(name);
		}
	}
	else {
		boolean found = false;
		paramValues = new ArrayList<String>();
		for (MultiValueMap<String, String> params : pathParameters.values()) {
			if (params.containsKey(name)) {
				if (found) {
					String paramType = parameter.getParameterType().getName();
					throw new ServletRequestBindingException(
							"Found more than one match for URI path parameter '" + name +
							"' for parameter type [" + paramType + "]. Use pathVar attribute to disambiguate.");
				}
				paramValues.addAll(params.get(name));
				found = true;
			}
		}
	}

	if (CollectionUtils.isEmpty(paramValues)) {
		return null;
	}
	else if (paramValues.size() == 1) {
		return paramValues.get(0);
	}
	else {
		return paramValues;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:48,代码来源:MatrixVariableMethodArgumentResolver.java


示例17: PathVariableNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
public PathVariableNamedValueInfo(PathVariable annotation) {
	super(annotation.value(), true, ValueConstants.DEFAULT_NONE);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:PathVariableMethodArgumentResolver.java


示例18: IdPathVariableNamedValueInfo

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
public IdPathVariableNamedValueInfo(MethodParameter parameter) {
	super(parameter.getParameterName(), true, ValueConstants.DEFAULT_NONE);
}
 
开发者ID:Cybernostics,项目名称:nanorest,代码行数:4,代码来源:IdPathArgumentResolver.java


示例19: isCustomDefaultValue

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
protected boolean isCustomDefaultValue(final String defaultValue) {
    return defaultValue != null && !ValueConstants.DEFAULT_NONE.equals(defaultValue);
}
 
开发者ID:ScaCap,项目名称:spring-auto-restdocs,代码行数:4,代码来源:AbstractParameterSnippet.java


示例20: hasDefaultValue

import org.springframework.web.bind.annotation.ValueConstants; //导入依赖的package包/类
private static boolean hasDefaultValue(RequestParam annot) {
    return !ValueConstants.DEFAULT_NONE.equals(annot.defaultValue());
}
 
开发者ID:ScaCap,项目名称:spring-auto-restdocs,代码行数:4,代码来源:RequestParametersSnippet.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JspSourceDependent类代码示例发布时间:2022-05-22
下一篇:
Java CloseReason类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap