Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Map<String, Map<String, Map<SchemaInternalOperation, List<SchemaCharge>>>> splitTotal(List<SchemaCharge> charges) {
- return MapSeq.map(splitByOffer(charges), (String k, List<SchemaCharge> v) -> {
- return MapSeq.map(splitByResource(v), w -> splitByOperation(w));
- });
- }
- private Map<String, List<SchemaCharge>> splitByOffer(List<SchemaCharge> charges) {
- return MapSeq.orderedGroupBy(charges, SchemaCharge::getOfferId);
- }
- private Map<String, List<SchemaCharge>> splitByResource(List<SchemaCharge> charges) {
- Map<String, List<SchemaCharge>> map = MapSeq.orderedGroupBy(charges, SchemaCharge::getSku);
- return MapSeq.map(
- map,
- chs -> chs.stream()
- .sorted(Comparator.comparing(
- ch -> ch.getStartDate()
- .map(Optional::of)
- .orElseGet(ch::getShipmentDate)
- .map(LocalDate::parse)
- .orElseGet(() -> LocalDate.from(ch.getCreateDatetime()))
- ))
- .collect(Collectors.toList())
- );
- }
- private Map<SchemaInternalOperation, List<SchemaCharge>> splitByOperation(List<SchemaCharge> charges) {
- return MapSeq.orderedGroupBy(charges, SchemaCharge::getOperation);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement