someproject.me.tomassetti.Agenda Maven / Gradle / Ivy
package me.tomassetti;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class Agenda {
private List persons = new ArrayList<>();
public void addPerson(Person person) {
persons.add(person);
}
public List findAddressesOfPersons(String personName) {
return persons.stream().
filter(p -> p.getName().equals(personName)).
map(p -> p.getAddress()).
collect(Collectors.toList());
}
}