Last active
August 29, 2015 14:28
-
-
Save jirkapenzes/5417892ba16946e410d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Map<String, Set<Rule>> ruleSets; | |
@Override | |
public Rule findRule(String ruleSetName, String route, String method) { | |
Set<Rule> rules = ruleSets.get(ruleSetName); | |
if (rules == null) | |
rules = new HashSet<>(); | |
Optional<Rule> detectedRule = rules.stream() | |
.filter(rule -> RouteMatcher.match(rule.getRoute(), route) | |
&& rule.getMethod().equals(method)) | |
.findFirst(); | |
return detectedRule.isPresent() ? detectedRule.get() : new DefaultRule(); | |
} |
Pěkné, díky! 👍 To jsem potřeboval
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nějak nevidím žádné for loopy :) ... takže to se streamy jde.
Mohl bys to ještě zkrátit na one-liner: