All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.xebia.extras.selma.beans.Order2OrderDtoSelmaGeneratedClass Maven / Gradle / Ivy

The newest version!
// GENERATED BY S3LM4
package fr.xebia.extras.selma.beans;


public final class Order2OrderDtoSelmaGeneratedClass
    implements Order2OrderDto {


  /**
   * This field is used for custom Mapping
   */
  private CustomMappings customMapperCustomMappings;

  /**
   * Custom Mapper setter for customMapperCustomMappings
   */
  public final void setCustomMapperCustomMappings(CustomMappings mapper) {
    this.customMapperCustomMappings = mapper;
  }


  /**
   * Single constructor
   */
  public Order2OrderDtoSelmaGeneratedClass() {
    this.customMapperCustomMappings = new fr.xebia.extras.selma.beans.CustomMappings();
  }

  /**
   * Mapping method overridden by Selma
   */
  @Override
  public final OrderDto to(Order in) {
    fr.xebia.extras.selma.beans.OrderDto out = null;
    if (in != null) {
      out = new fr.xebia.extras.selma.beans.OrderDto();
      out.setSalesChannel(asSalesChannelDto(in.getSalesChannel()));
      out.setCustomer(asCustomerDto(in.getCustomer()));
      if (in.getCreationDate() != null) {
        out.setCreationDate(new java.util.Date(in.getCreationDate().getTime()));
      }
      else {
        out.setCreationDate(null);
      }
      if (in.getProducts() != null) {
        java.util.ArrayList aproductsTmpCollection = new java.util.ArrayList(in.getProducts().size());
        out.setProducts(aproductsTmpCollection);
        for (fr.xebia.extras.selma.beans.Product aproductsItem : in.getProducts()) {
          aproductsTmpCollection.add(to(aproductsItem));
        }
      }
      else {
        out.setProducts(null);
      }
      out.setTotalAmount(in.getTotalAmount());
    }
    return out;
  }

  /**
   * Mapping method overridden by Selma
   */
  public final CustomerDto asCustomerDto(Customer in) {
    fr.xebia.extras.selma.beans.CustomerDto out = null;
    if (in != null) {
      out = new fr.xebia.extras.selma.beans.CustomerDto();
      out.setPhoneNumber(in.getPhoneNumber());
      out.setAddress(asAddressDto(in.getAddress()));
      out.setEmail(in.getEmail());
      out.setName(in.getName());
    }
    return out;
  }

  /**
   * Mapping method overridden by Selma
   */
  public final AddressDto asAddressDto(Address in) {
    fr.xebia.extras.selma.beans.AddressDto out = null;
    if (in != null) {
      out = new fr.xebia.extras.selma.beans.AddressDto();
      out.setStreetLine2(in.getStreetLine2());
      out.setStreetLine1(in.getStreetLine1());
      out.setCityLine(in.getCityLine());
    }
    return out;
  }

  /**
   * Mapping method overridden by Selma
   */
  public final SalesChannelDto asSalesChannelDto(SalesChannel in) {
    fr.xebia.extras.selma.beans.SalesChannelDto out = null;
    if (in != null) {
      switch (in) {
        case WEB :  {
          out = fr.xebia.extras.selma.beans.SalesChannelDto.WEB;
          break;
        }
        case SHOP :  {
          out = fr.xebia.extras.selma.beans.SalesChannelDto.SHOP;
          break;
        }
        case RETAILER :  {
          out = fr.xebia.extras.selma.beans.SalesChannelDto.RETAILER;
          break;
        }
        case PHONE :  {
          out = fr.xebia.extras.selma.beans.SalesChannelDto.PHONE;
          break;
        }
      }
    }
    return out;
  }


  /**
   * Mapping method overridden by Selma
   */
  @Override
  public final ProductDto to(Product in) {
    fr.xebia.extras.selma.beans.ProductDto out = null;
    if (in != null) {
      out = new fr.xebia.extras.selma.beans.ProductDto();
      if (in.getTags() != null) {
        java.util.HashSet atagsTmpCollection = new java.util.HashSet(in.getTags().size());
        out.setTags(atagsTmpCollection);
        for (java.lang.String atagsItem : in.getTags()) {
          atagsTmpCollection.add(atagsItem);
        }
      }
      else {
        out.setTags(null);
      }
      out.setPrice(in.getPrice());
      out.setLabel(in.getLabel());
      out.setCode(in.getCode());
      if (in.getType() != null) {
        out.setType(customMapperCustomMappings.productTypeToString(in.getType()));
      }
      else {
        out.setType(null);
      }
    }
    return out;
  }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy