/**
  * Compares "this" info (i.e. the current instance) with another info in the context of a request.
  *
  * <p>Note: it is assumed both instances have been obtained via {@link
  * #getMatchingInfo(HttpServletRequest)} to ensure they have conditions with content relevant to
  * current request.
  */
 public int compareTo(RequestMappingInfo other, HttpServletRequest request) {
   int result = patternsCondition.compareTo(other.getPatternsCondition(), request);
   if (result != 0) {
     return result;
   }
   result = paramsCondition.compareTo(other.getParamsCondition(), request);
   if (result != 0) {
     return result;
   }
   result = headersCondition.compareTo(other.getHeadersCondition(), request);
   if (result != 0) {
     return result;
   }
   result = consumesCondition.compareTo(other.getConsumesCondition(), request);
   if (result != 0) {
     return result;
   }
   result = producesCondition.compareTo(other.getProducesCondition(), request);
   if (result != 0) {
     return result;
   }
   result = methodsCondition.compareTo(other.getMethodsCondition(), request);
   if (result != 0) {
     return result;
   }
   result = customCondition.compareTo(other.customCondition, request);
   if (result != 0) {
     return result;
   }
   return 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());
  }
 @Override
 public int hashCode() {
   int result = hash;
   if (result == 0) {
     result = patternsCondition.hashCode();
     result = 31 * result + methodsCondition.hashCode();
     result = 31 * result + paramsCondition.hashCode();
     result = 31 * result + headersCondition.hashCode();
     result = 31 * result + consumesCondition.hashCode();
     result = 31 * result + producesCondition.hashCode();
     result = 31 * result + customCondition.hashCode();
     hash = result;
   }
   return result;
 }