public final class RemoveLineItem extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
withEmptyCartAndProduct(client(), (cart, product) -> { assertThat(cart.getLineItems()).hasSize(0); final AddLineItem action = AddLineItem.of(product.getId(), MASTER_VARIANT_ID, 3L); final Cart cartWith3 = client().executeBlocking(CartUpdateCommand.of(cart, action)); final LineItem lineItem = cartWith3.getLineItems().get(0); assertThat(lineItem.getQuantity()).isEqualTo(3); final Cart cartWith2 = client().executeBlocking(CartUpdateCommand.of(cartWith3, RemoveLineItem.of(lineItem, 1L))); assertThat(cartWith2.getLineItems().get(0).getQuantity()).isEqualTo(2); final Cart cartWith0 = client().executeBlocking(CartUpdateCommand.of(cartWith2, RemoveLineItem.of(lineItem))); assertThat(cartWith0.getLineItems()).hasSize(0); });
See the test code.
Modifier and Type | Method and Description |
---|---|
javax.money.MonetaryAmount |
getExternalPrice() |
ExternalLineItemTotalPrice |
getExternalTotalPrice() |
String |
getLineItemId() |
Long |
getQuantity() |
ItemShippingDetailsDraft |
getShippingDetailsToRemove() |
static RemoveLineItem |
of(LineItem lineItem) |
static RemoveLineItem |
of(LineItem lineItem,
Long quantity) |
static RemoveLineItem |
of(String lineItemId) |
static RemoveLineItem |
of(String lineItemId,
Long quantity) |
static RemoveLineItem |
of(String lineItemId,
Long quantity,
javax.money.MonetaryAmount externalPrice,
ExternalLineItemTotalPrice externalTotalPrice,
ItemShippingDetailsDraft shippingDetailsToRemove)
Creates a new object initialized with the given values.
|
static RemoveLineItem |
ofLineItemAndExternalPrice(LineItem lineItem,
Long quantity,
javax.money.MonetaryAmount externalPrice) |
static RemoveLineItem |
ofLineItemAndExternalPrice(String lineItemId,
Long quantity,
javax.money.MonetaryAmount externalPrice) |
static RemoveLineItem |
ofLineItemAndExternalTotalPrice(LineItem lineItem,
Long quantity,
ExternalLineItemTotalPrice externalTotalPrice) |
static RemoveLineItem |
ofLineItemAndExternalTotalPrice(String lineItemId,
Long quantity,
ExternalLineItemTotalPrice externalTotalPrice) |
RemoveLineItem |
withExternalPrice(javax.money.MonetaryAmount externalPrice)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
RemoveLineItem |
withExternalTotalPrice(ExternalLineItemTotalPrice externalTotalPrice)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
RemoveLineItem |
withQuantity(Long quantity)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
RemoveLineItem |
withShippingDetailsToRemove(ItemShippingDetailsDraft shippingDetailsToRemove)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
getAction
public static RemoveLineItem of(String lineItemId, @Nullable Long quantity)
public static RemoveLineItem of(String lineItemId)
public static RemoveLineItem of(LineItem lineItem, @Nullable Long quantity)
public static RemoveLineItem of(LineItem lineItem)
public static RemoveLineItem ofLineItemAndExternalPrice(LineItem lineItem, @Nullable Long quantity, @Nullable javax.money.MonetaryAmount externalPrice)
public static RemoveLineItem ofLineItemAndExternalPrice(String lineItemId, @Nullable Long quantity, @Nullable javax.money.MonetaryAmount externalPrice)
public static RemoveLineItem ofLineItemAndExternalTotalPrice(LineItem lineItem, @Nullable Long quantity, @Nullable ExternalLineItemTotalPrice externalTotalPrice)
public static RemoveLineItem ofLineItemAndExternalTotalPrice(String lineItemId, @Nullable Long quantity, @Nullable ExternalLineItemTotalPrice externalTotalPrice)
public String getLineItemId()
@Nullable public javax.money.MonetaryAmount getExternalPrice()
@Nullable public ExternalLineItemTotalPrice getExternalTotalPrice()
@Nullable public ItemShippingDetailsDraft getShippingDetailsToRemove()
public static RemoveLineItem of(String lineItemId, @Nullable Long quantity, @Nullable javax.money.MonetaryAmount externalPrice, @Nullable ExternalLineItemTotalPrice externalTotalPrice, @Nullable ItemShippingDetailsDraft shippingDetailsToRemove)
lineItemId
- initial value for the propertyquantity
- initial value for the propertyexternalPrice
- initial value for the propertyexternalTotalPrice
- initial value for the propertyshippingDetailsToRemove
- initial value for the propertypublic RemoveLineItem withQuantity(Long quantity)
public RemoveLineItem withExternalPrice(javax.money.MonetaryAmount externalPrice)
public RemoveLineItem withExternalTotalPrice(ExternalLineItemTotalPrice externalTotalPrice)
public RemoveLineItem withShippingDetailsToRemove(ItemShippingDetailsDraft shippingDetailsToRemove)