Skip to content

Instantly share code, notes, and snippets.

@NZhuravlev
Created May 19, 2016 13:04
Show Gist options
  • Save NZhuravlev/126d787abf14689dcc8586ecbd1246c6 to your computer and use it in GitHub Desktop.
Save NZhuravlev/126d787abf14689dcc8586ecbd1246c6 to your computer and use it in GitHub Desktop.
package com.doublescoring.socredit;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) {
int size = Arrays.asList(new OrderList(Arrays.asList(new Order(Arrays.asList("гавно", "шлак")))))
.stream()
.flatMap(orderList -> orderList.getOrders().stream())
.flatMap(order -> order.getProducts().stream())
.filter(s -> !"гавно".equals(s))
.collect(Collectors.toList()).size();
System.out.println(size);
}
public static class OrderList {
public OrderList(List<Order> orders) {
this.orders = orders;
}
private List<Order> orders;
public List<Order> getOrders() {
return orders;
}
public void setOrders(List<Order> orders) {
this.orders = orders;
}
}
public static class Order {
public Order(List<String> products) {
this.products = products;
}
private List<String> products;
public List<String> getProducts() {
return products;
}
public void setProducts(List<String> products) {
this.products = products;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment