Guest User

Untitled

a guest
Jan 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public Function<Order, Boolean> isBigOrder() {
  2.  
  3. Function<Order, Optional<Long>> sum = a -> a.getProducts()
  4. .stream()
  5. .map(P -> P.getPrice())
  6. .reduce((p1,p2)->p1+p2);
  7.  
  8. Predicate <Optional<Long>> isBig = x -> x.get() > 1000 ;
  9.  
  10. return ????;
  11. }
  12.  
  13. enum OrderState {CONFIRMED, PAID, WAREHOUSE_PROCESSED, READY_TO_SEND, DELIVERED }
  14.  
  15. enum ProductType { NORMAL, BREAKABLE, PERISHABLE }
  16.  
  17.  
  18.  
  19.  
  20. public class Product {
  21. private String code;
  22. private String title;
  23. private long price;
  24. private ProductState state;
  25. private ProductType type;
  26.  
  27. //all fields have getter and setter
  28.  
  29. public Product price(long price) {
  30. this.price = price;
  31. return this;
  32. }
  33. }
  34.  
  35.  
  36.  
  37.  
  38. public class Order {
  39.  
  40. private String code;
  41. private long price;
  42. private String buyyer;
  43. private OrderState state;
  44. private List<Product> products = new ArrayList<>();
  45.  
  46. //all fields have getter and setter
  47.  
  48. public Order price(long price) {
  49. this.price = price;
  50. return this;
  51. }
  52.  
  53. public Order product(Product product) {
  54. if (products == null) {
  55. products = new ArrayList<>();
  56. }
  57. products.add(product);
  58. return this;
  59. }
  60.  
  61. }
Add Comment
Please, Sign In to add comment