コード例 #1
0
  /**
   * 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
   */
  public RequestMappingInfo getMatchingInfo(HttpServletRequest request) {
    RequestMethodsRequestCondition methods = methodsCondition.getMatchingCondition(request);
    ParamsRequestCondition params = paramsCondition.getMatchingCondition(request);
    HeadersRequestCondition headers = headersCondition.getMatchingCondition(request);
    ConsumesRequestCondition consumes = consumesCondition.getMatchingCondition(request);
    ProducesRequestCondition produces = producesCondition.getMatchingCondition(request);

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

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

    CustomRequestCondition custom = customCondition.getMatchingCondition(request);
    if (custom == null) {
      return null;
    }

    return new RequestMappingInfo(
        patterns, methods, params, headers, consumes, produces, custom.getCondition());
  }
コード例 #2
0
  /**
   * Combines "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}
   */
  public RequestMappingInfo combine(RequestMappingInfo 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);
    CustomRequestCondition custom = this.customCondition.combine(other.customCondition);

    return new RequestMappingInfo(
        patterns, methods, params, headers, consumes, produces, custom.getCondition());
  }
コード例 #3
0
 /** Returns the "custom" condition of this {@link RequestMappingInfo}; or {@code null} */
 public RequestCondition<?> getCustomCondition() {
   return customCondition.getCondition();
 }