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

io.sphere.sdk.products.commands.updateactions.RemovePrice Maven / Gradle / Ivy

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

import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.products.Price;
import io.sphere.sdk.products.Product;

import java.util.Optional;

/**
 * Removes a price from the product.
 *
 * {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.products.commands.ProductUpdateCommandTest#removePrice()}
 */
public class RemovePrice extends UpdateActionImpl {
    private final String priceId;

    private RemovePrice(final String priceId) {
        super("removePrice");
        this.priceId = priceId;
    }

    public String getPriceId() {
        return priceId;
    }

    /**
     * Action to remove a price
     * @param price the price to remove including an ID
     * @return action
     */
    public static RemovePrice of(final Price price) {
        return of(Optional.ofNullable(price.getId()).orElseThrow(() -> new IllegalArgumentException("Expected price with ID.")));
    }

    public static RemovePrice of(final String priceId) {
        return new RemovePrice(priceId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy