Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. private Map<String, Map<String, Map<SchemaInternalOperation, List<SchemaCharge>>>> splitTotal(List<SchemaCharge> charges) {
  2. return MapSeq.map(splitByOffer(charges), (String k, List<SchemaCharge> v) -> {
  3. return MapSeq.map(splitByResource(v), w -> splitByOperation(w));
  4. });
  5. }
  6.  
  7. private Map<String, List<SchemaCharge>> splitByOffer(List<SchemaCharge> charges) {
  8. return MapSeq.orderedGroupBy(charges, SchemaCharge::getOfferId);
  9. }
  10.  
  11. private Map<String, List<SchemaCharge>> splitByResource(List<SchemaCharge> charges) {
  12. Map<String, List<SchemaCharge>> map = MapSeq.orderedGroupBy(charges, SchemaCharge::getSku);
  13. return MapSeq.map(
  14. map,
  15. chs -> chs.stream()
  16. .sorted(Comparator.comparing(
  17. ch -> ch.getStartDate()
  18. .map(Optional::of)
  19. .orElseGet(ch::getShipmentDate)
  20. .map(LocalDate::parse)
  21. .orElseGet(() -> LocalDate.from(ch.getCreateDatetime()))
  22. ))
  23. .collect(Collectors.toList())
  24. );
  25. }
  26.  
  27. private Map<SchemaInternalOperation, List<SchemaCharge>> splitByOperation(List<SchemaCharge> charges) {
  28. return MapSeq.orderedGroupBy(charges, SchemaCharge::getOperation);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement