Last active
October 7, 2016 17:38
-
-
Save eisenjulian/4a1423e42eb262bfcfc777751d24b20c 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
final Optional<Pattern> customerNamePattern = filters.stream().filter(m -> "customerName".equals(m.get("t"))) | |
.map(m -> m.get("_id_").toString().trim()) | |
.findAny() | |
.map(pattern -> Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); | |
final Optional<String> customerEmail = filters.stream().filter(m -> "customerEmail".equals(m.get("t"))) | |
.map(m -> m.get("_id_").toString().trim()) | |
.findAny(); | |
final Predicate<Customer> customerFilter = c -> | |
customerEmail.map(email -> c.EMAIL.hasData() && email.equalsIgnoreCase(c.EMAIL.get())).orElse(true) && | |
customerNamePattern.map(pattern -> pattern.matcher(c.getCompleteName()).find()).orElse(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment