io.sphere.sdk.productdiscounts.ProductDiscountValue Maven / Gradle / Ivy
package io.sphere.sdk.productdiscounts;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import javax.money.MonetaryAmount;
import java.util.Collections;
import java.util.List;
/**
* Defines discount type with the corresponding value. The type can be relative or absolute.
*
* @see RelativeProductDiscountValue
* @see AbsoluteProductDiscountValue
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = RelativeProductDiscountValue.class, name = "relative"),
@JsonSubTypes.Type(value = AbsoluteProductDiscountValue.class, name = "absolute") })
public interface ProductDiscountValue {
static AbsoluteProductDiscountValue ofAbsolute(final List money) {
return AbsoluteProductDiscountValue.of(money);
}
static AbsoluteProductDiscountValue ofAbsolute(final MonetaryAmount money) {
return AbsoluteProductDiscountValue.of(Collections.singletonList(money));
}
static RelativeProductDiscountValue ofRelative(final int permyriad) {
return RelativeProductDiscountValue.of(permyriad);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy