/** * Return declared "params" conditions but only among those that also * match the "methods", "consumes", and "params" conditions. */ public List<String[]> getParamConditions() { List<String[]> result = new ArrayList<>(); for (PartialMatch match : this.partialMatches) { if (match.hasProducesMatch()) { Set<NameValueExpression<String>> set = match.getInfo().getParamsCondition().getExpressions(); if (!CollectionUtils.isEmpty(set)) { int i = 0; String[] array = new String[set.size()]; for (NameValueExpression<String> expression : set) { array[i++] = expression.toString(); } result.add(array); } } } return result; }
/** * Return declared "params" conditions but only among those that also * match the "methods", "consumes", and "params" conditions. */ public List<String[]> getParamConditions() { List<String[]> result = new ArrayList<>(); for (PartialMatch match : this.partialMatches) { if (match.hasProducesMatch()) { Set<NameValueExpression<String>> set = match.getInfo().getParamsCondition().getExpressions(); if (!CollectionUtils.isEmpty(set)) { int i = 0; String[] array = new String[set.size()]; for (NameValueExpression<String> expression : set) { array[i++] = expression.toString(); } result.add(array); } } } return result; }
/** * Create a new {@link PartialMatch} instance. * @param info the RequestMappingInfo that matches the URL path. * @param request the current request */ public PartialMatch(RequestMappingInfo info, HttpServletRequest request) { this.info = info; this.methodsMatch = (info.getMethodsCondition().getMatchingCondition(request) != null); this.consumesMatch = (info.getConsumesCondition().getMatchingCondition(request) != null); this.producesMatch = (info.getProducesCondition().getMatchingCondition(request) != null); this.paramsMatch = (info.getParamsCondition().getMatchingCondition(request) != null); }
private RequestMappingInfo withPrefix(RequestMappingInfo mapping) { if (!StringUtils.hasText(adminContextPath)) { return mapping; } PatternsRequestCondition patternsCondition = new PatternsRequestCondition( withNewPatterns(mapping.getPatternsCondition().getPatterns())); return new RequestMappingInfo(patternsCondition, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); }
/** * Create a new {@link PartialMatch} instance. * @param info the RequestMappingInfo that matches the URL path. * @param request the current request */ public PartialMatch(RequestMappingInfo info, HttpServletRequest request) { this.info = info; this.methodsMatch = (info.getMethodsCondition().getMatchingCondition(request) != null); this.consumesMatch = (info.getConsumesCondition().getMatchingCondition(request) != null); this.producesMatch = (info.getProducesCondition().getMatchingCondition(request) != null); this.paramsMatch = (info.getParamsCondition().getMatchingCondition(request) != null); }
getPathMatcher(), useSuffixPatternMatch(), useTrailingSlashMatch(), getFileExtensions()); ParamsRequestCondition paramsInfo = defaultMapping.getParamsCondition(); if (!approvalParameter.equals(OAuth2Utils.USER_OAUTH_APPROVAL) && defaultPatterns.contains("/oauth/authorize")) { String[] params = new String[paramsInfo.getExpressions().size()];
return result; result = this.paramsCondition.compareTo(other.getParamsCondition(), request); if (result != 0) { return result;
@Test public void createEmpty() { RequestMappingInfo info = paths().build(); assertEquals(0, info.getPatternsCondition().getPatterns().size()); assertEquals(0, info.getMethodsCondition().getMethods().size()); assertEquals(true, info.getConsumesCondition().isEmpty()); assertEquals(true, info.getProducesCondition().isEmpty()); assertNotNull(info.getParamsCondition()); assertNotNull(info.getHeadersCondition()); assertNull(info.getCustomCondition()); }
return result; result = this.paramsCondition.compareTo(other.getParamsCondition(), request); if (result != 0) { return result;
RequestMappingConditionsDescription(RequestMappingInfo requestMapping) { this.consumes = requestMapping.getConsumesCondition().getExpressions().stream() .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); this.headers = requestMapping.getHeadersCondition().getExpressions().stream() .map(NameValueExpressionDescription::new).collect(Collectors.toList()); this.methods = requestMapping.getMethodsCondition().getMethods(); this.params = requestMapping.getParamsCondition().getExpressions().stream() .map(NameValueExpressionDescription::new).collect(Collectors.toList()); this.patterns = requestMapping.getPatternsCondition().getPatterns(); this.produces = requestMapping.getProducesCondition().getExpressions().stream() .map(MediaTypeExpressionDescription::new).collect(Collectors.toList()); }
private RequestMappingInfo withNewPatterns(RequestMappingInfo mapping, String[] patterns) { PatternsRequestCondition patternsCondition = new PatternsRequestCondition( patterns, null, null, useSuffixPatternMatch(), useTrailingSlashMatch(), null); return new RequestMappingInfo(patternsCondition, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); }
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMappingInfo info = super.getMappingForMethod(method, handlerType); if (info == null) { return null; } PatternsRequestCondition patternsCondition = customize(info.getPatternsCondition(), prefix); ProducesRequestCondition producesCondition = customize(info.getProducesCondition()); return new RequestMappingInfo(patternsCondition, info.getMethodsCondition(), info.getParamsCondition(), info.getHeadersCondition(), info.getConsumesCondition(), producesCondition, info.getCustomCondition()); }
@Override public Set<NameValueExpression<String>> params() { return requestMapping.getParamsCondition().getExpressions(); }
public Set<NameValueExpression<String>> params() { return requestMapping.getParamsCondition().getExpressions(); }
/** * Return declared "params" conditions but only among those that also * match the "methods", "consumes", and "params" conditions. */ public List<String[]> getParamConditions() { List<String[]> result = new ArrayList<String[]>(); for (PartialMatch match : this.partialMatches) { if (match.hasProducesMatch()) { Set<NameValueExpression<String>> set = match.getInfo().getParamsCondition().getExpressions(); if (!CollectionUtils.isEmpty(set)) { int i = 0; String[] array = new String[set.size()]; for (NameValueExpression<String> expression : set) { array[i++] = expression.toString(); } result.add(array); } } } return result; }
private RequestMappingInfo withPrefix(RequestMappingInfo mapping) { List<String> newPatterns = getPatterns(mapping); PatternsRequestCondition patterns = new PatternsRequestCondition( newPatterns.toArray(new String[newPatterns.size()])); return new RequestMappingInfo(patterns, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); }
/** * @param info RequestMappingInfo that matches the URL path. * @param request the current request */ public PartialMatch(RequestMappingInfo info, HttpServletRequest request) { this.info = info; this.methodsMatch = (info.getMethodsCondition().getMatchingCondition(request) != null); this.consumesMatch = (info.getConsumesCondition().getMatchingCondition(request) != null); this.producesMatch = (info.getProducesCondition().getMatchingCondition(request) != null); this.paramsMatch = (info.getParamsCondition().getMatchingCondition(request) != null); }
@Override protected void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping) { Class<?> beanType = method.getDeclaringClass(); if (AnnotationUtils.findAnnotation(beanType, RestController.class) != null) { PatternsRequestCondition apiPattern = new PatternsRequestCondition(apiBasePath) .combine(mapping.getPatternsCondition()); mapping = new RequestMappingInfo(mapping.getName(), apiPattern, mapping.getMethodsCondition(), mapping.getParamsCondition(), mapping.getHeadersCondition(), mapping.getConsumesCondition(), mapping.getProducesCondition(), mapping.getCustomCondition()); } super.registerHandlerMethod(handler, method, mapping); } };
@Override protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { RequestMappingInfo info = super.getMappingForMethod(method, handlerType); if (info == null) { return null; } PatternsRequestCondition patternsCondition = customize(info.getPatternsCondition(), prefix); ProducesRequestCondition producesCondition = customize(info.getProducesCondition()); return new RequestMappingInfo(patternsCondition, info.getMethodsCondition(), info.getParamsCondition(), info.getHeadersCondition(), info.getConsumesCondition(), producesCondition, info.getCustomCondition()); }
@Override public void apply(OperationContext context) { ParamsRequestCondition paramsCondition = context.getRequestMappingInfo().getParamsCondition(); List<Parameter> parameters = newArrayList(); for (NameValueExpression<String> expression : paramsCondition.getExpressions()) { if (skipParameter(parameters, expression)) { continue; } Parameter parameter = new ParameterBuilder() .name(expression.getName()) .description(null) .defaultValue(expression.getValue()) .required(true) .allowMultiple(false) .type(resolver.resolve(String.class)) .modelRef(new ModelRef("string")) .allowableValues(new AllowableListValues(newArrayList(expression.getValue()), "string")) .parameterType("query") .parameterAccess("") .build(); parameters.add(parameter); } context.operationBuilder().parameters(parameters); }