类org.springframework.web.servlet.mvc.condition.PatternsRequestCondition源码实例Demo

下面列出了怎么用org.springframework.web.servlet.mvc.condition.PatternsRequestCondition的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-analysis-note   文件: RequestMappingInfo.java
@Override
public RequestMappingInfo build() {
	ContentNegotiationManager manager = this.options.getContentNegotiationManager();

	PatternsRequestCondition patternsCondition = new PatternsRequestCondition(
			this.paths, this.options.getUrlPathHelper(), this.options.getPathMatcher(),
			this.options.useSuffixPatternMatch(), this.options.useTrailingSlashMatch(),
			this.options.getFileExtensions());

	return new RequestMappingInfo(this.mappingName, patternsCondition,
			new RequestMethodsRequestCondition(this.methods),
			new ParamsRequestCondition(this.params),
			new HeadersRequestCondition(this.headers),
			new ConsumesRequestCondition(this.consumes, this.headers),
			new ProducesRequestCondition(this.produces, this.headers, manager),
			this.customCondition);
}
 
源代码2 项目: spring-analysis-note   文件: CrossOriginTests.java
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
				new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
				new RequestMethodsRequestCondition(annotation.method()),
				new ParamsRequestCondition(annotation.params()),
				new HeadersRequestCondition(annotation.headers()),
				new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
				new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annot = AnnotationUtils.findAnnotation(method, RequestMapping.class);
	if (annot != null) {
		return new RequestMappingInfo(
			new PatternsRequestCondition(annot.value(), getUrlPathHelper(), getPathMatcher(), true, true),
			new RequestMethodsRequestCondition(annot.method()),
			new ParamsRequestCondition(annot.params()),
			new HeadersRequestCondition(annot.headers()),
			new ConsumesRequestCondition(annot.consumes(), annot.headers()),
			new ProducesRequestCondition(annot.produces(), annot.headers()), null);
	}
	else {
		return null;
	}
}
 
源代码4 项目: springdoc-openapi   文件: OpenApiResource.java
/**
 * Calculate path.
 *
 * @param restControllers the rest controllers
 * @param map the map
 */
protected void calculatePath(Map<String, Object> restControllers, Map<RequestMappingInfo, HandlerMethod> map) {
	for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map.entrySet()) {
		RequestMappingInfo requestMappingInfo = entry.getKey();
		HandlerMethod handlerMethod = entry.getValue();
		PatternsRequestCondition patternsRequestCondition = requestMappingInfo.getPatternsCondition();
		Set<String> patterns = patternsRequestCondition.getPatterns();
		Map<String, String> regexMap = new LinkedHashMap<>();
		for (String pattern : patterns) {
			String operationPath = PathUtils.parsePath(pattern, regexMap);
			if (((actuatorProvider.isPresent() && actuatorProvider.get().isRestController(operationPath))
					|| isRestController(restControllers, handlerMethod, operationPath))
					&& isPackageToScan(handlerMethod.getBeanType().getPackage())
					&& isPathToMatch(operationPath)) {
				Set<RequestMethod> requestMethods = requestMappingInfo.getMethodsCondition().getMethods();
				// default allowed requestmethods
				if (requestMethods.isEmpty())
					requestMethods = this.getDefaultAllowedHttpMethods();
				calculatePath(handlerMethod, operationPath, requestMethods);
			}
		}
	}
}
 
/**
 * Is search controller present boolean.
 *
 * @param requestMappingInfo the request mapping info
 * @param handlerMethod the handler method
 * @param requestMethod the request method
 * @return the boolean
 */
private boolean isSearchControllerPresent(RequestMappingInfo requestMappingInfo, HandlerMethod handlerMethod, RequestMethod requestMethod) {
	if (!UNDOCUMENTED_REQUEST_METHODS.contains(requestMethod)) {
		PatternsRequestCondition patternsRequestCondition = requestMappingInfo.getPatternsCondition();
		Set<String> patterns = patternsRequestCondition.getPatterns();
		Map<String, String> regexMap = new LinkedHashMap<>();
		String operationPath;
		for (String pattern : patterns) {
			operationPath = PathUtils.parsePath(pattern, regexMap);
			if (operationPath.contains(REPOSITORY_PATH) && operationPath.contains(SEARCH_PATH)) {
				MethodAttributes methodAttributes = new MethodAttributes(springDocConfigProperties.getDefaultConsumesMediaType(), springDocConfigProperties.getDefaultProducesMediaType());
				methodAttributes.calculateConsumesProduces(handlerMethod.getMethod());
				if (springDocConfigProperties.getDefaultProducesMediaType().equals(methodAttributes.getMethodProduces()[0]))
					return true;
			}
		}
	}
	return false;
}
 
源代码6 项目: spring-cloud-formula   文件: RateLimiterManager.java
private void updatePatternsRequestMap() {
    if (rateLimiterProperties == null
            || rateLimiterProperties.getRatelimiters() == null
            || rateLimiterProperties.getRatelimiters().size() <= 0) {
        setPatternsRequestMap(new ConcurrentHashMap<>());
    } else {
        Map<String, PatternsRequestCondition> patternsMap = new ConcurrentHashMap<>();
        rateLimiterProperties.getRatelimiters().forEach(limiterConfig -> {
            if (FormulaConfigUtils.isRateLimiterRuleMatch(limiterConfig) && limiterConfig.getEnabled()) {
                patternsMap.putIfAbsent(limiterConfig.getEffectiveLocation(),
                        new PatternsRequestCondition(limiterConfig.getEffectiveLocation()));
            }
        });
        setPatternsRequestMap(patternsMap);
        logger.info("Update RateLimiter rule pattern success, size: " + patternsMap.size());
    }
}
 
@Override
public RequestMappingInfo build() {
	ContentNegotiationManager manager = this.options.getContentNegotiationManager();

	PatternsRequestCondition patternsCondition = new PatternsRequestCondition(
			this.paths, this.options.getUrlPathHelper(), this.options.getPathMatcher(),
			this.options.useSuffixPatternMatch(), this.options.useTrailingSlashMatch(),
			this.options.getFileExtensions());

	return new RequestMappingInfo(this.mappingName, patternsCondition,
			new RequestMethodsRequestCondition(this.methods),
			new ParamsRequestCondition(this.params),
			new HeadersRequestCondition(this.headers),
			new ConsumesRequestCondition(this.consumes, this.headers),
			new ProducesRequestCondition(this.produces, this.headers, manager),
			this.customCondition);
}
 
源代码8 项目: java-technology-stack   文件: CrossOriginTests.java
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
				new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
				new RequestMethodsRequestCondition(annotation.method()),
				new ParamsRequestCondition(annotation.params()),
				new HeadersRequestCondition(annotation.headers()),
				new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
				new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annot = AnnotationUtils.findAnnotation(method, RequestMapping.class);
	if (annot != null) {
		return new RequestMappingInfo(
			new PatternsRequestCondition(annot.value(), getUrlPathHelper(), getPathMatcher(), true, true),
			new RequestMethodsRequestCondition(annot.method()),
			new ParamsRequestCondition(annot.params()),
			new HeadersRequestCondition(annot.headers()),
			new ConsumesRequestCondition(annot.consumes(), annot.headers()),
			new ProducesRequestCondition(annot.produces(), annot.headers()), null);
	}
	else {
		return null;
	}
}
 
源代码10 项目: api-mock-util   文件: RequestMappingService.java
public ApiBean registerApi(String index,String api,String requestMethod,String msg){
    check(!hasMethodOccupied(index),"该序号已经被占用,请先注销api。");
    check(!hasApiRegistered(api,requestMethod),"该api已经注册过了");

    RequestMappingHandlerMapping requestMappingHandlerMapping = webApplicationContext.getBean(RequestMappingHandlerMapping.class);
    Method targetMethod = ReflectionUtils.findMethod(ApiController.class, getHandlerMethodName(index)); // 找到处理该路由的方法

    PatternsRequestCondition patternsRequestCondition = new PatternsRequestCondition(api);
    RequestMethodsRequestCondition requestMethodsRequestCondition = new RequestMethodsRequestCondition(getRequestMethod(requestMethod));

    RequestMappingInfo mapping_info = new RequestMappingInfo(patternsRequestCondition, requestMethodsRequestCondition, null, null, null, null, null);
    requestMappingHandlerMapping.registerMapping(mapping_info, "apiController", targetMethod); // 注册映射处理

    // 保存注册信息到本地
    ApiBean apiInfo = new ApiBean();
    apiInfo.setApi(api);
    apiInfo.setRequestMethod(requestMethod);
    apiInfo.setMsg(msg);
    Constants.requestMappings.put(index,apiInfo);

    return apiInfo;
}
 
源代码11 项目: api-mock-util   文件: RequestMappingService.java
public boolean unregisterApi(String index,String api,String requestMethod){
    check(hasApiRegistered(api,requestMethod),"该api未注册过");

    RequestMappingHandlerMapping requestMappingHandlerMapping = webApplicationContext.getBean(RequestMappingHandlerMapping.class);
    Method targetMethod = ReflectionUtils.findMethod(ApiController.class, getHandlerMethodName(index));

    PatternsRequestCondition patternsRequestCondition = new PatternsRequestCondition(api);
    RequestMethodsRequestCondition requestMethodsRequestCondition = new RequestMethodsRequestCondition(getRequestMethod(requestMethod));
    RequestMappingInfo mapping_info = new RequestMappingInfo(patternsRequestCondition, requestMethodsRequestCondition, null, null, null, null, null);

    requestMappingHandlerMapping.unregisterMapping(mapping_info); // 注销

    if(Constants.requestMappings.containsKey(index)){
        Constants.requestMappings.remove(index);
    }

    return true;
}
 
protected RequestMappingInfo createRequestMappingInfoByApiMethodAnno(RequestMapping requestMapping, RequestCondition<?> customCondition,
                                                                     Method method) {
    String[] patterns = resolveEmbeddedValuesInPatterns(requestMapping.value());
    if (!method.isAnnotationPresent(RequestMapping.class) || CollectionUtil.isEmpty(patterns)) {
        RequestMappingResolveResult methodParsered = RequestMappingResolver.resolveOwnPath(method);
        String path = methodParsered.getPath();
        patterns = new String[] { path };
    }

    return new RequestMappingInfo(
        new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), this.useSuffixPatternMatch, this.useTrailingSlashMatch,
            this.fileExtensions),
        new RequestMethodsRequestCondition(requestMapping.method()), new ParamsRequestCondition(requestMapping.params()),
        new HeadersRequestCondition(requestMapping.headers()), new ConsumesRequestCondition(requestMapping.consumes(), requestMapping.headers()),
        new ProducesRequestCondition(requestMapping.produces(), requestMapping.headers(), this.contentNegotiationManager), customCondition);
}
 
@Test
public void getTest() {
    RequestMappingHandlerMapping handlerMapping = Mockito.mock(RequestMappingHandlerMapping.class);
    ExposedEndpointsController controller = new ExposedEndpointsController(new Gson(), handlerMapping);

    String endpoint1 = "/api/test";
    String endpoint2 = "/api/other/test";

    Map<RequestMappingInfo, HandlerMethod> handlerMethods = new HashMap<>();
    RequestMappingInfo info = new RequestMappingInfo(new PatternsRequestCondition(endpoint1, endpoint2), new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST), null, null, null, null, null);
    handlerMethods.put(info, null);

    Mockito.when(handlerMapping.getHandlerMethods()).thenReturn(handlerMethods);

    ResponseEntity<String> responseEntity = controller.get();
    Assertions.assertTrue(StringUtils.isNotBlank(responseEntity.getBody()), "Expected the response body to contain json");
}
 
源代码14 项目: lams   文件: RequestMappingInfo.java
/**
 * Checks if all conditions in this request mapping info match the provided request and returns
 * a potentially new request mapping info with conditions tailored to the current request.
 * <p>For example the returned instance may contain the subset of URL patterns that match to
 * the current request, sorted with best matching patterns on top.
 * @return a new instance in case all conditions match; or {@code null} otherwise
 */
@Override
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
	RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
	ParamsRequestCondition params = this.paramsCondition.getMatchingCondition(request);
	HeadersRequestCondition headers = this.headersCondition.getMatchingCondition(request);
	ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(request);
	ProducesRequestCondition produces = this.producesCondition.getMatchingCondition(request);

	if (methods == null || params == null || headers == null || consumes == null || produces == null) {
		return null;
	}

	PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
	if (patterns == null) {
		return null;
	}

	RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(request);
	if (custom == null) {
		return null;
	}

	return new RequestMappingInfo(this.name, patterns,
			methods, params, headers, consumes, produces, custom.getCondition());
}
 
源代码15 项目: lams   文件: RequestMappingInfo.java
@Override
public RequestMappingInfo build() {
	ContentNegotiationManager manager = this.options.getContentNegotiationManager();

	PatternsRequestCondition patternsCondition = new PatternsRequestCondition(
			this.paths, this.options.getUrlPathHelper(), this.options.getPathMatcher(),
			this.options.useSuffixPatternMatch(), this.options.useTrailingSlashMatch(),
			this.options.getFileExtensions());

	return new RequestMappingInfo(this.mappingName, patternsCondition,
			new RequestMethodsRequestCondition(methods),
			new ParamsRequestCondition(this.params),
			new HeadersRequestCondition(this.headers),
			new ConsumesRequestCondition(this.consumes, this.headers),
			new ProducesRequestCondition(this.produces, this.headers, manager),
			this.customCondition);
}
 
源代码16 项目: spring4-understanding   文件: RequestMappingInfo.java
@Override
public RequestMappingInfo build() {
	ContentNegotiationManager manager = this.options.getContentNegotiationManager();

	PatternsRequestCondition patternsCondition = new PatternsRequestCondition(
			this.paths, this.options.getUrlPathHelper(), this.options.getPathMatcher(),
			this.options.useSuffixPatternMatch(), this.options.useTrailingSlashMatch(),
			this.options.getFileExtensions());

	return new RequestMappingInfo(this.mappingName, patternsCondition,
			new RequestMethodsRequestCondition(methods),
			new ParamsRequestCondition(this.params),
			new HeadersRequestCondition(this.headers),
			new ConsumesRequestCondition(this.consumes, this.headers),
			new ProducesRequestCondition(this.produces, this.headers, manager),
			this.customCondition);
}
 
源代码17 项目: spring4-understanding   文件: CrossOriginTests.java
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
				new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
				new RequestMethodsRequestCondition(annotation.method()),
				new ParamsRequestCondition(annotation.params()),
				new HeadersRequestCondition(annotation.headers()),
				new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
				new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
@Test
public void matchPatternsCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");

	RequestMappingInfo info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo*", "/bar"), null, null, null, null, null, null);
	RequestMappingInfo expected = new RequestMappingInfo(
			new PatternsRequestCondition("/foo*"), null, null, null, null, null, null);

	assertEquals(expected, info.getMatchingCondition(request));

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/**", "/foo*", "/foo"), null, null, null, null, null, null);
	expected = new RequestMappingInfo(
			new PatternsRequestCondition("/foo", "/foo*", "/**"), null, null, null, null, null, null);

	assertEquals(expected, info.getMatchingCondition(request));
}
 
@Test
public void matchParamsCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setParameter("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null,
					new ParamsRequestCondition("foo=bar"), null, null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null,
			new ParamsRequestCondition("foo!=bar"), null, null, null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
@Test
public void matchHeadersCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.addHeader("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null, null,
					new HeadersRequestCondition("foo=bar"), null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null,
			new HeadersRequestCondition("foo!=bar"), null, null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
@Test
public void matchConsumesCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setContentType("text/plain");

	RequestMappingInfo info =
		new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null,
			new ConsumesRequestCondition("text/plain"), null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null,
			new ConsumesRequestCondition("application/xml"), null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
@Test
public void matchProducesCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.addHeader("Accept", "text/plain");

	RequestMappingInfo info =
		new RequestMappingInfo(
				new PatternsRequestCondition("/foo"), null, null, null, null,
				new ProducesRequestCondition("text/plain"), null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null, null,
			new ProducesRequestCondition("application/xml"), null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
@Test
public void matchCustomCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setParameter("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null, null, null, null, null,
					new ParamsRequestCondition("foo=bar"));
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null,
			new ParamsRequestCondition("foo!=bar"), null, null, null,
			new ParamsRequestCondition("foo!=bar"));
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
@Test
public void preFlightRequest() {
	MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/foo");
	request.addHeader(HttpHeaders.ORIGIN, "http://domain.com");
	request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST");

	RequestMappingInfo info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), new RequestMethodsRequestCondition(RequestMethod.POST), null,
			null, null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);
	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), new RequestMethodsRequestCondition(RequestMethod.OPTIONS), null,
			null, null, null, null);
	match = info.getMatchingCondition(request);
	assertNotNull(match);
}
 
@Test
public void uriTemplateVariables() {
	PatternsRequestCondition patterns = new PatternsRequestCondition("/{path1}/{path2}");
	RequestMappingInfo key = new RequestMappingInfo(patterns, null, null, null, null, null, null);
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/1/2");
	String lookupPath = new UrlPathHelper().getLookupPathForRequest(request);
	this.handlerMapping.handleMatch(key, lookupPath, request);

	@SuppressWarnings("unchecked")
	Map<String, String> uriVariables =
		(Map<String, String>) request.getAttribute(
				HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);

	assertNotNull(uriVariables);
	assertEquals("1", uriVariables.get("path1"));
	assertEquals("2", uriVariables.get("path2"));
}
 
@Test
public void uriTemplateVariablesDecode() {
	PatternsRequestCondition patterns = new PatternsRequestCondition("/{group}/{identifier}");
	RequestMappingInfo key = new RequestMappingInfo(patterns, null, null, null, null, null, null);
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/group/a%2Fb");

	UrlPathHelper pathHelper = new UrlPathHelper();
	pathHelper.setUrlDecode(false);
	String lookupPath = pathHelper.getLookupPathForRequest(request);

	this.handlerMapping.setUrlPathHelper(pathHelper);
	this.handlerMapping.handleMatch(key, lookupPath, request);

	@SuppressWarnings("unchecked")
	Map<String, String> uriVariables =
		(Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);

	assertNotNull(uriVariables);
	assertEquals("group", uriVariables.get("group"));
	assertEquals("a/b", uriVariables.get("identifier"));
}
 
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
			new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
源代码28 项目: spring-analysis-note   文件: RequestMappingInfo.java
public RequestMappingInfo(@Nullable String name, @Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this.name = (StringUtils.hasText(name) ? name : null);
	this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
	this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
	this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
	this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
	this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
	this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
	this.customConditionHolder = new RequestConditionHolder(custom);
}
 
源代码29 项目: spring-analysis-note   文件: RequestMappingInfo.java
/**
 * Creates a new instance with the given request conditions.
 */
public RequestMappingInfo(@Nullable PatternsRequestCondition patterns,
		@Nullable RequestMethodsRequestCondition methods, @Nullable ParamsRequestCondition params,
		@Nullable HeadersRequestCondition headers, @Nullable ConsumesRequestCondition consumes,
		@Nullable ProducesRequestCondition produces, @Nullable RequestCondition<?> custom) {

	this(null, patterns, methods, params, headers, consumes, produces, custom);
}
 
源代码30 项目: spring-analysis-note   文件: RequestMappingInfo.java
/**
 * Combine "this" request mapping info (i.e. the current instance) with another request mapping info instance.
 * <p>Example: combine type- and method-level request mappings.
 * @return a new request mapping info instance; never {@code null}
 */
@Override
public RequestMappingInfo combine(RequestMappingInfo other) {
	String name = combineNames(other);
	PatternsRequestCondition patterns = this.patternsCondition.combine(other.patternsCondition);
	RequestMethodsRequestCondition methods = this.methodsCondition.combine(other.methodsCondition);
	ParamsRequestCondition params = this.paramsCondition.combine(other.paramsCondition);
	HeadersRequestCondition headers = this.headersCondition.combine(other.headersCondition);
	ConsumesRequestCondition consumes = this.consumesCondition.combine(other.consumesCondition);
	ProducesRequestCondition produces = this.producesCondition.combine(other.producesCondition);
	RequestConditionHolder custom = this.customConditionHolder.combine(other.customConditionHolder);

	return new RequestMappingInfo(name, patterns,
			methods, params, headers, consumes, produces, custom.getCondition());
}
 
 类方法
 同包方法