private static void distinctEmployeeFirstNames(IMap<String, Employee> employees) { // create PropertyExtractor to extract firstName value from the employee PropertyExtractor<Employee, String> propertyExtractor = new FirstNamePropertyExtractor(); // select all employees Supplier<String, Employee, String> supplier = Supplier.all(propertyExtractor); // choose the aggregation to perform Aggregation<String, String, Set<String>> aggregation = Aggregations.distinctValues(); // execute the aggregation and print the result Set<String> allFirstNames = employees.aggregate(supplier, aggregation); System.out.println("All first names: " + allFirstNames); System.out.println("\n"); // in Java 8: //Set<String> allFirstNames = employees.aggregate(Supplier.all((value) -> value.getFirstName()), // Aggregations.distinctValues()); }