@Override public int compare(final PriceInformation priceInfo1, final PriceInformation priceInfo2) { final Long o1Quantity = (Long) priceInfo1.getQualifierValue(PriceRow.MINQTD); final Long o2Quantity = (Long) priceInfo2.getQualifierValue(PriceRow.MINQTD); if (o1Quantity == null && o2Quantity == null) { return 0; } if (o1Quantity == null) { return -1; } if (o2Quantity == null) { return 1; } if (o1Quantity.longValue() == o2Quantity.longValue()) { final PriceValue pv1 = priceInfo1.getPriceValue(); final PriceValue pv2 = priceInfo2.getPriceValue(); return Double.compare(pv1.getValue(), pv2.getValue()); } return o1Quantity.compareTo(o2Quantity); }
protected void addDeliveryMethod( final AbstractOrderModel source, final AbstractOrderData prototype) { final DeliveryModeModel deliveryMode = source.getDeliveryMode(); if (deliveryMode != null) { // unnecessary if? if (deliveryMode instanceof ZoneDeliveryModeModel) { final ZoneDeliveryModeData zoneDeliveryModeData = getZoneDeliveryModeConverter().convert((ZoneDeliveryModeModel) deliveryMode); final PriceValue deliveryCost = getDeliveryService() .getDeliveryCostForDeliveryModeAndAbstractOrder(deliveryMode, source); if (deliveryCost != null) { zoneDeliveryModeData.setDeliveryCost( getPriceDataFactory() .create( PriceDataType.BUY, BigDecimal.valueOf(deliveryCost.getValue()), deliveryCost.getCurrencyIso())); } prototype.setDeliveryMode(zoneDeliveryModeData); } else { final DeliveryModeData deliveryModeData = getDeliveryModeConverter().convert(deliveryMode); final PriceValue deliveryCost = getDeliveryService() .getDeliveryCostForDeliveryModeAndAbstractOrder(deliveryMode, source); if (deliveryCost != null) { deliveryModeData.setDeliveryCost( getPriceDataFactory() .create( PriceDataType.BUY, BigDecimal.valueOf(deliveryCost.getValue()), deliveryCost.getCurrencyIso())); } prototype.setDeliveryMode(deliveryModeData); } } }