Example #1
0
 public int getTotalAmount() {
   if (productSelectedList == null) return 0;
   int totalAmount = 0;
   for (ProductSelected productSelected : productSelectedList) {
     totalAmount += productSelected.getAmount();
   }
   return totalAmount;
 }
Example #2
0
 public void merge(ProductSelected anotherProductSelected) {
   List<ProductSelected> productSelectedList = this.getProductSelectedList();
   if (productSelectedList == null) {
     productSelectedList = new ArrayList<ProductSelected>();
     productSelectedList.add(anotherProductSelected);
     this.setProductSelectedList(productSelectedList);
     return;
   }
   for (ProductSelected thisProductSelected : this.getProductSelectedList()) {
     if (thisProductSelected.equals(anotherProductSelected)) {
       int amount = thisProductSelected.getAmount() == null ? 0 : thisProductSelected.getAmount();
       thisProductSelected.setAmount(amount + anotherProductSelected.getAmount());
       return;
     }
   }
   productSelectedList.add(anotherProductSelected);
   //        setProductSelectedList(productSelectedList);
 }
Example #3
0
 public double getTotalPrice() {
   if (productSelectedList == null) return 0d;
   double totalPrice = 0d;
   for (ProductSelected productSelected : productSelectedList) {
     Assert.notNull(productSelected.getProductSeries());
     if (productSelected.getProductSeries().getCurrentPrice() == null) totalPrice += 0;
     else
       totalPrice +=
           productSelected.getAmount()
               * productSelected.getProductSeries().getCurrentPrice().getPrice();
   }
   return totalPrice;
 }
Example #4
0
 public void merge(Cart anotherCart) {
   if (anotherCart == null) return;
   if (anotherCart.getProductSelectedList() == null) return;
   List<ProductSelected> thisProductSelectedList = this.getProductSelectedList();
   if (thisProductSelectedList == null) {
     this.setProductSelectedList(anotherCart.getProductSelectedList());
     return;
   }
   outer:
   for (ProductSelected anotherProductSelected : anotherCart.getProductSelectedList()) {
     inner:
     for (ProductSelected thisProductSelected : this.getProductSelectedList()) {
       if (thisProductSelected.equals(anotherProductSelected)) {
         thisProductSelected.setAmount(
             thisProductSelected.getAmount() + anotherProductSelected.getAmount());
         break outer;
       }
     }
     thisProductSelectedList.add(anotherProductSelected);
     //            setProductSelectedList(thisProductSelectedList);
   }
 }