Class TextLineItemUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.shoppinglists.utils.TextLineItemUpdateActionUtils
-
public final class TextLineItemUpdateActionUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildChangeTextLineItemNameUpdateAction(io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares theLocalizedString
names ofTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"changeTextLineItemName"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildChangeTextLineItemQuantityUpdateAction(io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares thequantity
values of aTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"changeTextLineItemQuantity"
UpdateAction
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildSetTextLineItemDescriptionUpdateAction(io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares theLocalizedString
descriptions ofTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"setTextLineItemDescription"
UpdateAction
.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildTextLineItemCustomUpdateActions(io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem, ShoppingListSyncOptions syncOptions)
Compares the custom fields and custom types of aTextLineItem
and aTextLineItemDraft
and returns a list ofUpdateAction
<ShoppingList
> as a result.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildTextLineItemsUpdateActions(io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, ShoppingListSyncOptions syncOptions)
Compares a list ofTextLineItem
s with a list ofTextLineItemDraft
s.static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>>
buildTextLineItemUpdateActions(io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem, ShoppingListSyncOptions syncOptions)
Compares all the fields of aTextLineItem
and aTextLineItemDraft
and returns a list ofUpdateAction
<ShoppingList
> as a result.
-
-
-
Method Detail
-
buildTextLineItemsUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildTextLineItemsUpdateActions(@Nonnull io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, @Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, @Nonnull ShoppingListSyncOptions syncOptions)
Compares a list ofTextLineItem
s with a list ofTextLineItemDraft
s. The method takes in functions for building the required update actions (AddTextLineItem, RemoveTextLineItem and 1-1 update actions on text line items (e.g. changeTextLineItemQuantity, setTextLineItemCustomType, etc..).If the list of new
TextLineItemDraft
s isnull
, then remove actions are built for every existing text line item.- Parameters:
oldShoppingList
- shopping list resource, whose text line items should be updated.newShoppingList
- new shopping list draft, which contains the text line items to update.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- a list of text line item update actions on the resource of shopping lists, if the list of text line items are not identical. Otherwise, if the text line items are identical, an empty list is returned.
-
buildTextLineItemUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildTextLineItemUpdateActions(@Nonnull io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, @Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, @Nonnull io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, @Nonnull io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem, @Nonnull ShoppingListSyncOptions syncOptions)
Compares all the fields of aTextLineItem
and aTextLineItemDraft
and returns a list ofUpdateAction
<ShoppingList
> as a result. If both theTextLineItem
and theTextLineItemDraft
have identical fields, then no update action is needed and hence an emptyList
is returned.- Parameters:
oldShoppingList
- shopping list resource, whose line item should be updated.newShoppingList
- new shopping list draft, which contains the line item to update.oldTextLineItem
- the text line item which should be updated.newTextLineItem
- the text line item draft where we get the new fields (i.e. quantity, custom fields).syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the update actions or an empty list if the text line item fields are identical.
-
buildChangeTextLineItemNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildChangeTextLineItemNameUpdateAction(@Nonnull io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, @Nonnull io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares theLocalizedString
names ofTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"changeTextLineItemName"
UpdateAction
. If both theTextLineItem
and theTextLineItemDraft
have the samedescription
values, then no update action is needed and hence an empty optional will be returned.- Parameters:
oldTextLineItem
- the text line item which should be updated.newTextLineItem
- the text line item draft where we get the new name.- Returns:
- A filled optional with the update action or an empty optional if the names are identical.
-
buildSetTextLineItemDescriptionUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildSetTextLineItemDescriptionUpdateAction(@Nonnull io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, @Nonnull io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares theLocalizedString
descriptions ofTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"setTextLineItemDescription"
UpdateAction
. If both theTextLineItem
and theTextLineItemDraft
have the samedescription
values, then no update action is needed and hence an empty optional will be returned.- Parameters:
oldTextLineItem
- the text line item which should be updated.newTextLineItem
- the text line item draft where we get the new description.- Returns:
- A filled optional with the update action or an empty optional if the descriptions are identical.
-
buildChangeTextLineItemQuantityUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildChangeTextLineItemQuantityUpdateAction(@Nonnull io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, @Nonnull io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
Compares thequantity
values of aTextLineItem
and aTextLineItemDraft
and returns anOptional
of update action, which would contain the"changeTextLineItemQuantity"
UpdateAction
. If bothTextLineItem
andTextLineItemDraft
have the samequantity
values, then no update action is needed and empty optional will be returned.Note: If
quantity
from thenewTextLineItem
isnull
, the newquantity
will be set to default value1L
. Ifquantity
from thenewTextLineItem
is0
, then it means removing the text line item.- Parameters:
oldTextLineItem
- the text line item which should be updated.newTextLineItem
- the text line item draft where we get the new quantity.- Returns:
- A filled optional with the update action or an empty optional if the quantities are identical.
-
buildTextLineItemCustomUpdateActions
@Nonnull public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildTextLineItemCustomUpdateActions(@Nonnull io.sphere.sdk.shoppinglists.ShoppingList oldShoppingList, @Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraft newShoppingList, @Nonnull io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, @Nonnull io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem, @Nonnull ShoppingListSyncOptions syncOptions)
Compares the custom fields and custom types of aTextLineItem
and aTextLineItemDraft
and returns a list ofUpdateAction
<ShoppingList
> as a result. If both theTextLineItem
and theTextLineItemDraft
have identical custom fields and types, then no update action is needed and hence an emptyList
is returned.- Parameters:
oldShoppingList
- shopping list resource, whose text line item should be updated.newShoppingList
- new shopping list draft, which contains the text line item to update.oldTextLineItem
- the text line item which should be updated.newTextLineItem
- the text line item draft where we get the new custom fields and types.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the custom field/type update actions or an empty list if the custom fields/types are identical.
-
-