Last active
May 12, 2016 01:23
-
-
Save stevenwcarter/9ebb46c1e25d3b71e1b44d907de00ed0 to your computer and use it in GitHub Desktop.
Java 7 -> 8
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
// Old way of writing it | |
List<PartFilter> partFilters = FilterQueryBuilder.getFilters(PartFilter.class, clonedFilters); | |
for (PartFilter f : partFilters) { | |
if (f.getPartTerms() != null) { | |
f.getPartTerms().remove("sub_category"); | |
} | |
} | |
// New way with Java 8 Stream API and Lambda functions | |
FilterQueryBuilder.getFilters(PartFilter.class, clonedFilters).stream() | |
.filter(f -> f.getPartTerms() != null) | |
.forEach(filter -> filter.getPartTerms().remove("sub_category")); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment