Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Function<Order, Boolean> isBigOrder() {
- Function<Order, Optional<Long>> sum = a -> a.getProducts()
- .stream()
- .map(P -> P.getPrice())
- .reduce((p1,p2)->p1+p2);
- Predicate <Optional<Long>> isBig = x -> x.get() > 1000 ;
- return ????;
- }
- enum OrderState {CONFIRMED, PAID, WAREHOUSE_PROCESSED, READY_TO_SEND, DELIVERED }
- enum ProductType { NORMAL, BREAKABLE, PERISHABLE }
- public class Product {
- private String code;
- private String title;
- private long price;
- private ProductState state;
- private ProductType type;
- //all fields have getter and setter
- public Product price(long price) {
- this.price = price;
- return this;
- }
- }
- public class Order {
- private String code;
- private long price;
- private String buyyer;
- private OrderState state;
- private List<Product> products = new ArrayList<>();
- //all fields have getter and setter
- public Order price(long price) {
- this.price = price;
- return this;
- }
- public Order product(Product product) {
- if (products == null) {
- products = new ArrayList<>();
- }
- products.add(product);
- return this;
- }
- }
Add Comment
Please, Sign In to add comment