org.broadleafcommerce.core.offer.domain
Class CandidateItemOfferImpl

java.lang.Object
  extended by org.broadleafcommerce.core.offer.domain.CandidateQualifiedOfferImpl
      extended by org.broadleafcommerce.core.offer.domain.CandidateItemOfferImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, CandidateItemOffer, CandidateOffer, CandidateQualifiedOffer

@Entity
public class CandidateItemOfferImpl
extends CandidateQualifiedOfferImpl
implements CandidateItemOffer, java.lang.Cloneable

See Also:
Serialized Form

Field Summary
protected  java.lang.Long id
           
static org.apache.commons.logging.Log LOG
           
protected  Offer offer
           
protected  OrderItem orderItem
           
protected  Money potentialSavings
           
static long serialVersionUID
           
 
Fields inherited from class org.broadleafcommerce.core.offer.domain.CandidateQualifiedOfferImpl
candidateQualifiersMap, candidateTargets
 
Constructor Summary
CandidateItemOfferImpl()
           
 
Method Summary
protected  int calculateMaximumNumberOfUses()
          Determines the maximum number of times this promotion can be used based on the ItemCriteria and promotion's maxQty setting.
protected  int calculateMaxUsesForItemCriteria(OfferItemCriteria itemCriteria, Offer promotion)
           
protected  Money calculatePotentialSavings()
          This method determines how much the customer might save using this promotion for the purpose of sorting promotions with the same priority.
 void checkCloneable(CandidateItemOffer itemOffer)
           
 CandidateItemOffer clone()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.Long getId()
           
 Offer getOffer()
           
 OrderItem getOrderItem()
           
 Money getPotentialSavings()
           
 int getPriority()
           
 int hashCode()
           
 void setId(java.lang.Long id)
           
 void setOffer(Offer offer)
           
 void setOrderItem(OrderItem orderItem)
           
 
Methods inherited from class org.broadleafcommerce.core.offer.domain.CandidateQualifiedOfferImpl
calculateSavingsForOrderItem, getCandidateQualifiersMap, getCandidateTargets, setCandidateQualifiersMap, setCandidateTargets
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.broadleafcommerce.core.offer.domain.CandidateQualifiedOffer
calculateSavingsForOrderItem, getCandidateQualifiersMap, getCandidateTargets, setCandidateQualifiersMap, setCandidateTargets
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

id

protected java.lang.Long id

orderItem

protected OrderItem orderItem

offer

protected Offer offer

potentialSavings

protected Money potentialSavings
Constructor Detail

CandidateItemOfferImpl

public CandidateItemOfferImpl()
Method Detail

getId

public java.lang.Long getId()
Specified by:
getId in interface CandidateOffer

setId

public void setId(java.lang.Long id)
Specified by:
setId in interface CandidateOffer

getOrderItem

public OrderItem getOrderItem()
Specified by:
getOrderItem in interface CandidateItemOffer

setOrderItem

public void setOrderItem(OrderItem orderItem)
Specified by:
setOrderItem in interface CandidateItemOffer

setOffer

public void setOffer(Offer offer)
Specified by:
setOffer in interface CandidateOffer

getPriority

public int getPriority()
Specified by:
getPriority in interface CandidateOffer

getOffer

public Offer getOffer()
Specified by:
getOffer in interface CandidateOffer

getPotentialSavings

public Money getPotentialSavings()
Specified by:
getPotentialSavings in interface CandidateItemOffer

calculatePotentialSavings

protected Money calculatePotentialSavings()
This method determines how much the customer might save using this promotion for the purpose of sorting promotions with the same priority. The assumption is that any possible target specified for BOGO style offers are of equal or lesser value. We are using a calculation based on the qualifiers here strictly for rough comparative purposes. If two promotions have the same priority, the one with the highest potential savings will be used as the tie-breaker to determine the order to apply promotions. This method makes a good approximation of the promotion value as determining the exact value would require all permutations of promotions to be run resulting in a costly operation.

Returns:

calculateMaximumNumberOfUses

protected int calculateMaximumNumberOfUses()
Determines the maximum number of times this promotion can be used based on the ItemCriteria and promotion's maxQty setting.


calculateMaxUsesForItemCriteria

protected int calculateMaxUsesForItemCriteria(OfferItemCriteria itemCriteria,
                                              Offer promotion)

checkCloneable

public void checkCloneable(CandidateItemOffer itemOffer)
                    throws java.lang.CloneNotSupportedException,
                           java.lang.SecurityException,
                           java.lang.NoSuchMethodException
Throws:
java.lang.CloneNotSupportedException
java.lang.SecurityException
java.lang.NoSuchMethodException

clone

public CandidateItemOffer clone()
Specified by:
clone in interface CandidateItemOffer
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2011. All Rights Reserved.