Iterable<String> filterSpecsByOperation(ImmutableMap<String, RestxSpec> allSpecs, String httpMethod, String path) { StdRestxRequestMatcher matcher = new StdRestxRequestMatcher(httpMethod, path); Collection<String> specs = Lists.newArrayList(); for (Map.Entry<String, RestxSpec> spec : allSpecs.entrySet()) { for (When when : spec.getValue().getWhens()) { if (when instanceof WhenHttpRequest) { WhenHttpRequest request = (WhenHttpRequest) when; String requestPath = request.getPath(); if (!requestPath.startsWith("/")) { requestPath = "/" + requestPath; } if (requestPath.indexOf("?") != -1) { requestPath = requestPath.substring(0, requestPath.indexOf("?")); } Optional<? extends RestxRequestMatch> match = matcher.match(request.getMethod(), requestPath); if (match.isPresent()) { specs.add(spec.getKey()); break; } } } } return specs; }
Iterable<String> filterSpecsByOperation(ImmutableMap<String, RestxSpec> allSpecs, String httpMethod, String path) { StdRestxRequestMatcher matcher = new StdRestxRequestMatcher(httpMethod, path); Collection<String> specs = Lists.newArrayList(); for (Map.Entry<String, RestxSpec> spec : allSpecs.entrySet()) { for (When when : spec.getValue().getWhens()) { if (when instanceof WhenHttpRequest) { WhenHttpRequest request = (WhenHttpRequest) when; String requestPath = request.getPath(); if (!requestPath.startsWith("/")) { requestPath = "/" + requestPath; } if (requestPath.indexOf("?") != -1) { requestPath = requestPath.substring(0, requestPath.indexOf("?")); } Optional<? extends RestxRequestMatch> match = matcher.match(request.getMethod(), requestPath); if (match.isPresent()) { specs.add(spec.getKey()); break; } } } } return specs; }