All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mangofactory.swagger.scanners.RegexRequestMappingPatternMatcher Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package com.mangofactory.swagger.scanners;

import org.springframework.util.Assert;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;

import java.util.List;
import java.util.Set;

public class RegexRequestMappingPatternMatcher implements RequestMappingPatternMatcher {

  @Override
  public boolean patternConditionsMatchOneOfIncluded(PatternsRequestCondition patternsCondition,
      List includePatterns) {

    Set patterns = patternsCondition.getPatterns();
    for (String path : patterns) {
      if (pathMatchesOneOfIncluded(path, includePatterns)) {
        return true;
      }
    }
    return false;
  }

  @Override
  public boolean pathMatchesOneOfIncluded(String path, List includePatterns) {
    for (String includePattern : includePatterns) {
      Assert.notNull(includePattern, "Include patterns should never be null");
      if (path.matches(includePattern)) {
        return true;
      }
    }
    return false;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy