Class LineItemDiscount
- java.lang.Object
-
- de.hybris.order.calculation.domain.AbstractDiscount
-
- de.hybris.order.calculation.domain.LineItemDiscount
-
public class LineItemDiscount extends AbstractDiscount
Holds a discounts specific for aLineItem
. The discount holds a amount (can beMoney
orPercentage
) which can only be set during creation (seeAbstractDiscount.getAmount()
). Further it either applies per unit or per line (seeisPerUnit()
). In case it applies per unit it may be limited to just a certain amount of units ( seegetApplicableUnits()
).
-
-
Constructor Summary
Constructors Constructor Description LineItemDiscount(AbstractAmount amount)
Creates a new line item discount with the given amount.LineItemDiscount(AbstractAmount amount, boolean perUnit)
Creates a new line item discount with given amount.LineItemDiscount(AbstractAmount amount, boolean perUnit, int applicableUnits)
Creates a new line item discount with given amount.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getApplicableUnits()
In case this discount applied per unit this returns the maximum number of units that it should apply to.boolean
isPerUnit()
Tell whether this discount should be applied for each unit or just once for the whole line.void
setApplicableUnits(int numberOfUnits)
For the case this discount applies per unit this method changes the maximum number of units to apply to.java.lang.String
toString()
-
Methods inherited from class de.hybris.order.calculation.domain.AbstractDiscount
getAmount
-
-
-
-
Constructor Detail
-
LineItemDiscount
public LineItemDiscount(AbstractAmount amount)
Creates a new line item discount with the given amount. This discount applies per line.
-
LineItemDiscount
public LineItemDiscount(AbstractAmount amount, boolean perUnit)
Creates a new line item discount with given amount. Depending on the given parameters it either applies per unit or per line.- Parameters:
amount
- the discount amountperUnit
- iftrue
it applies per unit, otherwise per line
-
LineItemDiscount
public LineItemDiscount(AbstractAmount amount, boolean perUnit, int applicableUnits)
Creates a new line item discount with given amount. Depending on the given parameters it either applies per unit or per line.- Parameters:
amount
- the discount amountperUnit
- iftrue
it applies per unit, otherwise per lineapplicableUnits
- when applying per unit this contains the maximum applicable number of units
-
-
Method Detail
-
isPerUnit
public boolean isPerUnit()
Tell whether this discount should be applied for each unit or just once for the whole line. In case of per unit the number of units are limited bygetApplicableUnits()
.
-
getApplicableUnits
public int getApplicableUnits()
In case this discount applied per unit this returns the maximum number of units that it should apply to. Otherwise this has no effect.- See Also:
isPerUnit()
-
setApplicableUnits
public void setApplicableUnits(int numberOfUnits)
For the case this discount applies per unit this method changes the maximum number of units to apply to.- See Also:
isPerUnit()
,getApplicableUnits()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-