Interface DiscountedPrice
Example to create an instance using the builder pattern
DiscountedPrice discountedPrice = DiscountedPrice.builder()
.value(valueBuilder -> valueBuilder)
.discount(discountBuilder -> discountBuilder)
.build()
-
Method Summary
Modifier and TypeMethodDescriptionstatic DiscountedPriceBuilderbuilder()builder factory method for DiscountedPricestatic DiscountedPriceBuilderbuilder(DiscountedPrice template) create builder for DiscountedPrice instancecopyDeep()static DiscountedPricedeepCopy(DiscountedPrice template) factory method to create a deep copy of DiscountedPrice@NotNull @Valid ProductDiscountReferenceProductDiscount related to the discounted price.@NotNull @Valid TypedMoneygetValue()Money value of the discounted price.static DiscountedPriceof()factory methodstatic DiscountedPriceof(DiscountedPrice template) factory method to create a shallow copy DiscountedPricevoidsetDiscount(ProductDiscountReference discount) ProductDiscount related to the discounted price.voidsetValue(TypedMoney value) Money value of the discounted price.static tools.jackson.core.type.TypeReference<DiscountedPrice>gives a TypeReference for usage with Jackson DataBinddefault <T> TwithDiscountedPrice(Function<DiscountedPrice, T> helper) accessor map function
-
Method Details
-
getValue
Money value of the discounted price.
When a relative Product Discount applies and the fractional part of the resulting discounted price is 0.5, the discounted price is rounded half down.
For example, a price of €1.01 (
centAmount: 101) with a 50% discount (permyriad: 5000) calculates to €0.505. Since the fractional half-cent is exactly 0.5, it rounds down to €0.50 (centAmount: 50).When an absolute Product Discount exceeds the price of the Product Variant, the resulting discounted price is set to
0.
- Returns:
- value
-
getDiscount
ProductDiscount related to the discounted price.
- Returns:
- discount
-
setValue
Money value of the discounted price.
When a relative Product Discount applies and the fractional part of the resulting discounted price is 0.5, the discounted price is rounded half down.
For example, a price of €1.01 (
centAmount: 101) with a 50% discount (permyriad: 5000) calculates to €0.505. Since the fractional half-cent is exactly 0.5, it rounds down to €0.50 (centAmount: 50).When an absolute Product Discount exceeds the price of the Product Variant, the resulting discounted price is set to
0.
- Parameters:
value- value to be set
-
setDiscount
ProductDiscount related to the discounted price.
- Parameters:
discount- value to be set
-
of
factory method- Returns:
- instance of DiscountedPrice
-
of
factory method to create a shallow copy DiscountedPrice- Parameters:
template- instance to be copied- Returns:
- copy instance
-
copyDeep
DiscountedPrice copyDeep() -
deepCopy
factory method to create a deep copy of DiscountedPrice- Parameters:
template- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for DiscountedPrice- Returns:
- builder
-
builder
create builder for DiscountedPrice instance- Parameters:
template- instance with prefilled values for the builder- Returns:
- builder
-
withDiscountedPrice
accessor map function- Type Parameters:
T- mapped type- Parameters:
helper- function to map the object- Returns:
- mapped value
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-