com.elasticpath.domain.catalog.impl
Class AbstractPriceImpl

java.lang.Object
  extended by com.elasticpath.domain.impl.AbstractEpDomainImpl
      extended by com.elasticpath.domain.impl.AbstractPersistenceImpl
          extended by com.elasticpath.domain.impl.AbstractValueObjectImpl
              extended by com.elasticpath.domain.catalog.impl.AbstractPriceImpl
All Implemented Interfaces:
Price, EpDomain, Persistence, ValueObject, java.io.Serializable
Direct Known Subclasses:
ProductPriceImpl, SkuPriceImpl

public class AbstractPriceImpl
extends AbstractValueObjectImpl
implements Price

The abstact implementation of Price. ProductPriceImpl and SkuPriceImpl will extend AbstractPriceImpl

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Constructor Summary
AbstractPriceImpl()
           
 
Method Summary
 void addOrUpdatePriceTier(PriceTier priceTier)
          Add the price Tiers.
 void clearComputedPrice()
          Removes the computed price for all price tier.
 Money getComputedPrice()
          Get the product's computed price of the first price tier.
 Money getComputedPrice(int qty)
          Get the product's computed price (e.g.
 java.util.Currency getCurrency()
          Get the currency for this product price.
 Money getDollarSavings()
          Calculates the MoneyImpl savings if the price has a discount.
 Money getDollarSavings(int qty)
          Calculates the MoneyImpl savings if the price has a discount.
 Money getListPrice()
          Get the product's list price of the first price tier.
 Money getListPrice(int qty)
          Get the product's list price.
 Money getLowestPrice()
          Get the lowest of the price values of the first price tier.
 Money getLowestPrice(int qty)
          Get the lowest of the price values specified in this Price.
 Money getPrePromotionPrice()
          Get the pre-promotion price of the first price tier to which promotions are to be applied.
 Money getPrePromotionPrice(int qty)
          Get the pre-promotion price of the corresponding price tier, which promotions are to be applied.
 PriceTier getPriceTierByExactMinQty(int minQty)
          Get the Price tier with the same minimum quantity with the inputed min Qty.
 java.util.Map getPriceTiers()
          Get the price Tiers.
 Money getSalePrice()
          Get the product's sale price of the first price tier.
 Money getSalePrice(int qty)
          Get the product's sale price.
 boolean hasPriceTiers()
          Check if the product has price tiers.
 boolean isLowestLessThanList()
          Check if the lowest price is less than the list price, i.e.
 boolean isLowestLessThanList(int qty)
          Check if the lowest price is less than the list price, i.e.
 void setComputedPrice(Money computedPrice)
          Set the computed price for the first price tier.
 void setComputedPrice(Money computedPrice, int minQty)
          Set the product's computed price (e.g.
 void setCurrency(java.util.Currency currency)
          Set the currency for the price.
 void setDefaultValues()
          Set default values for those fields need default values.
 void setListPrice(Money listPrice)
          Set the product's list price for the first price tier.
 void setListPrice(Money listPrice, int minQty)
          Set the product's list price.
 void setPriceTiers(java.util.Map priceTiers)
          set the price Tiers.
 void setSalePrice(Money salePrice)
          Set the product's sale price for the first price tier.
 void setSalePrice(Money salePrice, int minQty)
          Set the product's sale price.
 
Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

AbstractPriceImpl

public AbstractPriceImpl()
Method Detail

addOrUpdatePriceTier

public void addOrUpdatePriceTier(PriceTier priceTier)
Add the price Tiers.

Specified by:
addOrUpdatePriceTier in interface Price
Parameters:
priceTier - the price tier to be added

clearComputedPrice

public void clearComputedPrice()
Removes the computed price for all price tier.

Specified by:
clearComputedPrice in interface Price

getComputedPrice

public Money getComputedPrice()
Get the product's computed price of the first price tier.

Specified by:
getComputedPrice in interface Price
Returns:
the computed price as a MoneyImpl

getComputedPrice

public Money getComputedPrice(int qty)
Get the product's computed price (e.g. the result of executing a rule).

Specified by:
getComputedPrice in interface Price
Parameters:
qty - the quantity of the product
Returns:
the computed price as a MoneyImpl Returns null if no computed price has been set

getCurrency

public java.util.Currency getCurrency()
Get the currency for this product price.

Specified by:
getCurrency in interface Price
Returns:
the Currency

getDollarSavings

public Money getDollarSavings()
Calculates the MoneyImpl savings if the price has a discount.

Specified by:
getDollarSavings in interface Price
Returns:
the price savings as a MoneyImpl

getDollarSavings

public Money getDollarSavings(int qty)
Calculates the MoneyImpl savings if the price has a discount.

Specified by:
getDollarSavings in interface Price
Parameters:
qty - the quantity of the product
Returns:
the price savings as a MoneyImpl

getListPrice

public Money getListPrice()
Get the product's list price of the first price tier.

Specified by:
getListPrice in interface Price
Returns:
the list price as a MoneyImpl

getListPrice

public Money getListPrice(int qty)
Get the product's list price.

Specified by:
getListPrice in interface Price
Parameters:
qty - the quantity of the product
Returns:
the list price as a MoneyImpl

getLowestPrice

public Money getLowestPrice()
Get the lowest of the price values of the first price tier.

Specified by:
getLowestPrice in interface Price
Returns:
the lowest price as a MoneyImpl

getLowestPrice

public Money getLowestPrice(int qty)
Get the lowest of the price values specified in this Price.

Specified by:
getLowestPrice in interface Price
Parameters:
qty - the quantity of the product
Returns:
the lowest price as a MoneyImpl

getPrePromotionPrice

public Money getPrePromotionPrice()
Get the pre-promotion price of the first price tier to which promotions are to be applied. This is currently the lower of the sale price and the list price.

Specified by:
getPrePromotionPrice in interface Price
Returns:
a Money object representing the pre-promotion price

getPrePromotionPrice

public Money getPrePromotionPrice(int qty)
Get the pre-promotion price of the corresponding price tier, which promotions are to be applied. This is currently the lower of the sale price and the list price.

Specified by:
getPrePromotionPrice in interface Price
Parameters:
qty - the quantity of the product
Returns:
a Money object representing the pre-promotion price

getPriceTierByExactMinQty

public PriceTier getPriceTierByExactMinQty(int minQty)
Get the Price tier with the same minimum quantity with the inputed min Qty.

Specified by:
getPriceTierByExactMinQty in interface Price
Parameters:
minQty - the minumum quantity to be matched
Returns:
the matched PriceTier

getPriceTiers

public java.util.Map getPriceTiers()
Get the price Tiers.

Specified by:
getPriceTiers in interface Price
Returns:
the price tiers for this product price as a PriceTierImpl

getSalePrice

public Money getSalePrice()
Get the product's sale price of the first price tier.

Specified by:
getSalePrice in interface Price
Returns:
the sale price as a MoneyImpl

getSalePrice

public Money getSalePrice(int qty)
Get the product's sale price.

Specified by:
getSalePrice in interface Price
Parameters:
qty - the quantity of the product
Returns:
the sale price as a MoneyImpl

hasPriceTiers

public boolean hasPriceTiers()
Check if the product has price tiers. Each product should at least has one price (default price tier) set up.

Specified by:
hasPriceTiers in interface Price
Returns:
true if the product has more than one price tiers for different minimum quantity false if the product has only one price tier or no price tier set up

isLowestLessThanList

public boolean isLowestLessThanList()
Check if the lowest price is less than the list price, i.e. the price has a discount.

Specified by:
isLowestLessThanList in interface Price
Returns:
true if the price has a lower price than the list price.

isLowestLessThanList

public boolean isLowestLessThanList(int qty)
Check if the lowest price is less than the list price, i.e. the price has a discount.

Specified by:
isLowestLessThanList in interface Price
Parameters:
qty - the quantity of the product
Returns:
true if the price has a lower price than the list price.

setComputedPrice

public void setComputedPrice(Money computedPrice)
Set the computed price for the first price tier.

Specified by:
setComputedPrice in interface Price
Parameters:
computedPrice - the computed price as a MoneyImpl

setComputedPrice

public void setComputedPrice(Money computedPrice,
                             int minQty)
Set the product's computed price (e.g. the result of executing a rule). A computed price cannot be less than zero. If a negative price is specified, the computed price will be set to zero.

Specified by:
setComputedPrice in interface Price
Parameters:
computedPrice - the product's computed price as a MoneyImpl
minQty - the minimum quantity of the PriceTier

setCurrency

public void setCurrency(java.util.Currency currency)
Set the currency for the price.

Specified by:
setCurrency in interface Price
Parameters:
currency - of the price as a Currency

setDefaultValues

public void setDefaultValues()
Set default values for those fields need default values.

Specified by:
setDefaultValues in interface Persistence
Overrides:
setDefaultValues in class AbstractPersistenceImpl

setListPrice

public void setListPrice(Money listPrice)
Set the product's list price for the first price tier.

Specified by:
setListPrice in interface Price
Parameters:
listPrice - the product's list price as a MoneyImpl

setListPrice

public void setListPrice(Money listPrice,
                         int minQty)
Set the product's list price.

Specified by:
setListPrice in interface Price
Parameters:
listPrice - the product's list price as a MoneyImpl
minQty - the minimum quantity of the PriceTier

setPriceTiers

public void setPriceTiers(java.util.Map priceTiers)
set the price Tiers.

Specified by:
setPriceTiers in interface Price
Parameters:
priceTiers - the price tiers as a map of PriceTier

setSalePrice

public void setSalePrice(Money salePrice)
Set the product's sale price for the first price tier.

Specified by:
setSalePrice in interface Price
Parameters:
salePrice - the product's sale price as a MoneyImpl

setSalePrice

public void setSalePrice(Money salePrice,
                         int minQty)
Set the product's sale price.

Specified by:
setSalePrice in interface Price
Parameters:
salePrice - the product's sale price as a MoneyImpl
minQty - the minimum quantity of the PriceTier