public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Set<Object> seen = ConcurrentHashMap.newKeySet();
return t -> seen.add(keyExtractor.apply(t));
}
persons.stream().filter(distinctByKey(Person::getName))
public Set<String> areas(final List<Employee> employees) {
Set<String> areas = new HashSet<>();
for(final Employee employee: employees) {
areas.add(employee.getArea());
}
return areas;
}