GLS ShipIT
GLS ShipIT - SOAP services
 All Classes Namespaces Files Functions Variables Enumerator Pages
ConverterUtils.java
Go to the documentation of this file.
1 package eu.glsgroup.fpcs.soap.util;
2 
3 import eu.glsgroup.fpcs.datatypes.soap.v1.common.AddOnLiabilityService;
4 import eu.glsgroup.fpcs.datatypes.soap.v1.common.CashService;
5 import eu.glsgroup.fpcs.datatypes.soap.v1.common.CategoryType;
6 import eu.glsgroup.fpcs.datatypes.soap.v1.common.DeliveryAtWorkService;
7 import eu.glsgroup.fpcs.datatypes.soap.v1.common.DepositService;
8 import eu.glsgroup.fpcs.datatypes.soap.v1.common.ExWorksService;
9 import eu.glsgroup.fpcs.datatypes.soap.v1.common.ExchangeService;
10 import eu.glsgroup.fpcs.datatypes.soap.v1.common.HazardousGoodsService;
11 import eu.glsgroup.fpcs.datatypes.soap.v1.common.IdentPINService;
12 import eu.glsgroup.fpcs.datatypes.soap.v1.common.IdentService;
13 import eu.glsgroup.fpcs.datatypes.soap.v1.common.IntercompanyService;
14 import eu.glsgroup.fpcs.datatypes.soap.v1.common.LimitedQuantitiesService;
15 import eu.glsgroup.fpcs.datatypes.soap.v1.common.PickAndReturnService;
16 import eu.glsgroup.fpcs.datatypes.soap.v1.common.PickAndShipService;
17 import eu.glsgroup.fpcs.datatypes.soap.v1.common.Service;
18 import eu.glsgroup.fpcs.datatypes.soap.v1.common.ShipmentService;
19 import eu.glsgroup.fpcs.datatypes.soap.v1.common.ShopDeliveryService;
20 import eu.glsgroup.fpcs.datatypes.soap.v1.common.ShopReturnService;
21 import eu.glsgroup.fpcs.datatypes.soap.v1.common.UnitService;
22 import eu.glsgroup.fpcs.dto.ConsigneeCategory;
23 
24 import java.util.List;
25 import java.util.Optional;
26 import java.util.stream.Collectors;
27 import java.util.stream.Stream;
28 
29 public final class ConverterUtils {
30 
31  //Suppress default constructor for non-instantiability
32  private ConverterUtils() {
33 
34  throw new AssertionError("ConverterUtils cannot be instantiated.");
35  }
36 
37  public static ConsigneeCategory convertCategoryType(CategoryType categoryType) {
38 
39  if (categoryType == null) {
40  return null;
41  }
42  switch (categoryType) {
43  case PRIVATE:
44  return ConsigneeCategory.PRIVATE;
45  case BUSINESS:
46  return ConsigneeCategory.BUSINESS;
47  default:
48  throw new IllegalArgumentException("Unexpected categoryType '" + categoryType + "'");
49  }
50  }
51 
52  public static List<String> convertUnitService(UnitService unitService) {
53 
54  return Stream.of(Optional.ofNullable(unitService.getCash())
56  Optional.ofNullable(unitService.getAddonLiability())
58  Optional.ofNullable(unitService.getHazardousGoods())
60  Optional.ofNullable(unitService.getExWorks())
62  Optional.ofNullable(unitService.getLimitedQuantities())
64  .filter(Optional::isPresent)
65  .map(Optional::get)
66  .collect(Collectors.toList());
67  }
68 
69  public static List<String> convertShipmentService(ShipmentService shipmentService) {
70 
71  return Stream.of(Optional.ofNullable(shipmentService.getService())
73  Optional.ofNullable(shipmentService.getShopDelivery())
75  Optional.ofNullable(shipmentService.getShopReturn())
77  Optional.ofNullable(shipmentService.getIntercompany())
79  Optional.ofNullable(shipmentService.getExchange())
81  Optional.ofNullable(shipmentService.getDeliveryAtWork())
83  Optional.ofNullable(shipmentService.getDeposit())
85  Optional.ofNullable(shipmentService.getIdentPin())
87  Optional.ofNullable(shipmentService.getIdent())
89  Optional.ofNullable(shipmentService.getPickAndShip())
91  Optional.ofNullable(shipmentService.getPickAndReturn())
93  .filter(Optional::isPresent)
94  .map(Optional::get)
95  .collect(Collectors.toList());
96  }
97 }