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

io.sphere.sdk.carts.commands.updateactions.ChangeLineItemQuantity Maven / Gradle / Ivy

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

import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.carts.LineItem;
import io.sphere.sdk.commands.UpdateAction;
import io.sphere.sdk.commands.UpdateActionImpl;

/**
 Sets the quantity of the given line item. If quantity is 0, line item is removed from the cart.

 {@doc.gen intro}

 {@include.example io.sphere.sdk.carts.commands.CartUpdateCommandTest#changeLineItemQuantity()}
 */
public class ChangeLineItemQuantity extends UpdateActionImpl {
    private final String lineItemId;
    private final long quantity;

    private ChangeLineItemQuantity(final String lineItemId, final long quantity) {
        super("changeLineItemQuantity");
        this.lineItemId = lineItemId;
        this.quantity = quantity;
    }

    public String getLineItemId() {
        return lineItemId;
    }

    public long getQuantity() {
        return quantity;
    }

    public static ChangeLineItemQuantity of(final String lineItemId, final long quantity) {
        return new ChangeLineItemQuantity(lineItemId, quantity);
    }

    public static UpdateAction of(final LineItem lineItem, final long quantity) {
        return of(lineItem.getId(), quantity);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy