All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.cartdiscounts.CartDiscountValue Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.cartdiscounts;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import javax.money.MonetaryAmount;
import java.util.Collections;
import java.util.List;

@JsonTypeInfo(
        use = JsonTypeInfo.Id.NAME,
        include = JsonTypeInfo.As.PROPERTY,
        property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = RelativeCartDiscountValue.class, name = "relative"),
        @JsonSubTypes.Type(value = AbsoluteCartDiscountValue.class, name = "absolute") })
public interface CartDiscountValue {
        static AbsoluteCartDiscountValue ofAbsolute(final List money) {
                return AbsoluteCartDiscountValue.of(money);
        }

        static AbsoluteCartDiscountValue ofAbsolute(final MonetaryAmount money) {
                return AbsoluteCartDiscountValue.of(Collections.singletonList(money));
        }

        static RelativeCartDiscountValue ofRelative(final int permyriad) {
                return RelativeCartDiscountValue.of(permyriad);
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy