Skip to content

Instantly share code, notes, and snippets.

@cajar1988 cajar1988/ Secret
Last active Oct 30, 2015

What would you like to do?
public List<Person> fetchPeopleFrom_pureJava(String city) {
List<Person> result = new ArrayList<>();
List<Person> allPersons = fetchAll();
for (Person person : allPersons) {
Address address = person.getAddress();
String personCity = address.getCity();
if (personCity.equals(city)) {
return result;
public List<Person> fetchPeopleFrom_jdk8(String city) {
return fetchAll().stream()
.filter(person -> person.getAddress().getCity().equals(city))
public javaslang.collection.List<Person> fetchPeopleFrom_jslang(String city) {
return ofAll(fetchAll())
.filter(person -> person.getAddress().getCity().equals(city));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.