Class 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildChangeTextLineItemNameUpdateAction​(com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem, com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
      Compares the LocalizedString names of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemName" ShoppingListUpdateAction.
      static java.util.Optional<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildChangeTextLineItemQuantityUpdateAction​(com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem, com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
      Compares the quantity values of a TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemQuantity" ShoppingListUpdateAction.
      static java.util.Optional<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildSetTextLineItemDescriptionUpdateAction​(com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem, com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
      Compares the LocalizedString descriptions of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "setTextLineItemDescription" ShoppingListUpdateAction.
      static java.util.List<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemCustomUpdateActions​(com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList, com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList, com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem, com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem, ShoppingListSyncOptions syncOptions)
      Compares the custom fields and custom types of a TextLineItem and a TextLineItemDraft and returns a list of ShoppingListUpdateAction<ShoppingList> as a result.
      static java.util.List<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemsUpdateActions​(com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList, com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList, ShoppingListSyncOptions syncOptions)
      Compares a list of TextLineItems with a list of TextLineItemDrafts.
      static java.util.List<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemUpdateActions​(com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList, com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList, com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem, com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem, ShoppingListSyncOptions syncOptions)
      Compares all the fields of a TextLineItem and a TextLineItemDraft and returns a list of ShoppingListUpdateAction as a result.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • buildTextLineItemsUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemsUpdateActions​(@Nonnull
                                                                                                                                          com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList,
                                                                                                                                          @Nonnull
                                                                                                                                          com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList,
                                                                                                                                          @Nonnull
                                                                                                                                          ShoppingListSyncOptions syncOptions)
        Compares a list of TextLineItems with a list of TextLineItemDrafts. 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 TextLineItemDrafts is null, 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemUpdateActions​(@Nonnull
                                                                                                                                         com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList,
                                                                                                                                         @Nonnull
                                                                                                                                         com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList,
                                                                                                                                         @Nonnull
                                                                                                                                         com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem,
                                                                                                                                         @Nonnull
                                                                                                                                         com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem,
                                                                                                                                         @Nonnull
                                                                                                                                         ShoppingListSyncOptions syncOptions)
        Compares all the fields of a TextLineItem and a TextLineItemDraft and returns a list of ShoppingListUpdateAction as a result. If both the TextLineItem and the TextLineItemDraft have identical fields, then no update action is needed and hence an empty List 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildChangeTextLineItemNameUpdateAction​(@Nonnull
                                                                                                                                                      com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem,
                                                                                                                                                      @Nonnull
                                                                                                                                                      com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
        Compares the LocalizedString names of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemName" ShoppingListUpdateAction. If both the TextLineItem and the TextLineItemDraft have the same description 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildSetTextLineItemDescriptionUpdateAction​(@Nonnull
                                                                                                                                                          com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem,
                                                                                                                                                          @Nonnull
                                                                                                                                                          com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
        Compares the LocalizedString descriptions of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "setTextLineItemDescription" ShoppingListUpdateAction. If both the TextLineItem and the TextLineItemDraft have the same description 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildChangeTextLineItemQuantityUpdateAction​(@Nonnull
                                                                                                                                                          com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem,
                                                                                                                                                          @Nonnull
                                                                                                                                                          com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem)
        Compares the quantity values of a TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemQuantity" ShoppingListUpdateAction. If both TextLineItem and TextLineItemDraft have the same quantity values, then no update action is needed and empty optional will be returned.

        Note: If quantity from the newTextLineItem is null, the new quantity will be set to default value 1L. If quantity from the newTextLineItem is 0, 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<com.commercetools.api.models.shopping_list.ShoppingListUpdateAction> buildTextLineItemCustomUpdateActions​(@Nonnull
                                                                                                                                               com.commercetools.api.models.shopping_list.ShoppingList oldShoppingList,
                                                                                                                                               @Nonnull
                                                                                                                                               com.commercetools.api.models.shopping_list.ShoppingListDraft newShoppingList,
                                                                                                                                               @Nonnull
                                                                                                                                               com.commercetools.api.models.shopping_list.TextLineItem oldTextLineItem,
                                                                                                                                               @Nonnull
                                                                                                                                               com.commercetools.api.models.shopping_list.TextLineItemDraft newTextLineItem,
                                                                                                                                               @Nonnull
                                                                                                                                               ShoppingListSyncOptions syncOptions)
        Compares the custom fields and custom types of a TextLineItem and a TextLineItemDraft and returns a list of ShoppingListUpdateAction<ShoppingList> as a result. If both the TextLineItem and the TextLineItemDraft have identical custom fields and types, then no update action is needed and hence an empty List 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.