private RouteEntry findTargetWithGivenAcceptType( List<RouteEntry> routeMatchs, String acceptType) { if (acceptType != null && routeMatchs.size() > 0) { Map<String, RouteEntry> acceptedMimeTypes = getAcceptedMimeTypes(routeMatchs); String bestMatch = MimeParse.bestMatch(acceptedMimeTypes.keySet(), acceptType); if (routeWithGivenAcceptType(bestMatch)) { return acceptedMimeTypes.get(bestMatch); } else { return null; } } else { if (routeMatchs.size() > 0) { return routeMatchs.get(0); } } return null; }
@Override public List<RouteMatch> findTargetsForRequestedRoute( HttpMethod httpMethod, String path, String acceptType) { List<RouteMatch> matchSet = new ArrayList<RouteMatch>(); List<RouteEntry> routeEntries = this.findTargetsForRequestedRoute(httpMethod, path); for (RouteEntry routeEntry : routeEntries) { if (acceptType != null) { String bestMatch = MimeParse.bestMatch(Arrays.asList(routeEntry.acceptedType), acceptType); if (routeWithGivenAcceptType(bestMatch)) { matchSet.add( new RouteMatch(httpMethod, routeEntry.target, routeEntry.path, path, acceptType)); } } else { matchSet.add( new RouteMatch(httpMethod, routeEntry.target, routeEntry.path, path, acceptType)); } } return matchSet; }