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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.shoppinglists.ShoppingList>> buildChangeTextLineItemNameUpdateAction​(io.sphere.sdk.shoppinglists.TextLineItem oldTextLineItem, io.sphere.sdk.shoppinglists.TextLineItemDraft newTextLineItem)
      Compares the LocalizedString names of TextLineItem and a TextLineItemDraft and returns an Optional 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 the quantity values of a TextLineItem and a TextLineItemDraft and returns an Optional 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 the LocalizedString descriptions of TextLineItem and a TextLineItemDraft and returns an Optional 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 a TextLineItem and a TextLineItemDraft and returns a list of UpdateAction<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 of TextLineItems with a list of TextLineItemDrafts.
      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 a TextLineItem and a TextLineItemDraft and returns a list of UpdateAction<ShoppingList> 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<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 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<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 a TextLineItem and a TextLineItemDraft and returns a list of UpdateAction<ShoppingList> 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<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 the LocalizedString names of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemName" UpdateAction. 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<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 the LocalizedString descriptions of TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "setTextLineItemDescription" UpdateAction. 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<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 the quantity values of a TextLineItem and a TextLineItemDraft and returns an Optional of update action, which would contain the "changeTextLineItemQuantity" UpdateAction. 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<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 a TextLineItem and a TextLineItemDraft and returns a list of UpdateAction<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.