List of usage examples for java.util.stream Collectors partitioningBy
public static <T, D, A> Collector<T, ?, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate, Collector<? super T, A, D> downstream)
From source file:Main.java
public static void main(String... args) { Map<Boolean, Map<Type, List<Food>>> o = Food.menu.stream() .collect(Collectors.partitioningBy(Food::isVegetarian, Collectors.groupingBy(Food::getType))); System.out.println(o);/*from w ww . j av a 2 s. co m*/ }
From source file:Main.java
public static void main(String... args) { Map<Boolean, Food> o = Food.menu.stream().collect(Collectors.partitioningBy(Food::isVegetarian, Collectors .collectingAndThen(Collectors.maxBy(Comparator.comparingInt(Food::getCalories)), Optional::get))); System.out.println(o);/*from ww w .ja va2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { Map<Boolean, String> partionedByMaleGender = Employee.persons().stream().collect(Collectors .partitioningBy(Employee::isMale, Collectors.mapping(Employee::getName, Collectors.joining(", ")))); System.out.println(partionedByMaleGender); }