Class DefaultCartItemMergingService<I extends com.broadleafcommerce.cart.client.domain.CartItem>
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I>
-
- com.broadleafcommerce.cartoperation.service.DefaultCartItemMergingService<I>
-
- All Implemented Interfaces:
CartItemMergingService<I>,ItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I>
public class DefaultCartItemMergingService<I extends com.broadleafcommerce.cart.client.domain.CartItem> extends AbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I> implements CartItemMergingService<I>
The default implementation of a cart item merging service.- Author:
- Skye Pekerti
-
-
Constructor Summary
Constructors Constructor Description DefaultCartItemMergingService(CartOperationServiceProviders providers, CartOperationServiceProperties properties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoMergeCombine(@NonNull MergeItemPair<I> itemPair)Perform the actual combination of two items (quantity change) for the combination merge type.protected Collection<I>getItemsFromContainer(@NonNull com.broadleafcommerce.cart.client.domain.Cart container, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Gets the from the item container.protected com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()protected CartOperationServicePropertiesgetProperties()protected CartOperationServiceProvidersgetProviders()protected StringhashMatchingCriteria(I item)Generates a hash for any information on the item that should be used to determine if they represent the same item configuration.protected booleanisSameItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item1, @NonNull com.broadleafcommerce.cart.client.domain.CartItem item2)Tells if two item instances are actually the same instance.protected voidresolveMergeTypes(@NonNull List<MergeItemPair<I>> mergeItemPairs, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Determines what merge types should be used for the items and applies it to the merge item pairs.-
Methods inherited from class com.broadleafcommerce.cartoperation.service.AbstractItemMergingService
findMatchingItems, findMatchingItems, handleRejectedMerges, merge, mergeCombine, mergeIgnore, mergeItems, mergeSeparate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.cartoperation.service.ItemMergingService
mergeItems
-
-
-
-
Constructor Detail
-
DefaultCartItemMergingService
public DefaultCartItemMergingService(CartOperationServiceProviders providers, CartOperationServiceProperties properties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Detail
-
getItemsFromContainer
protected Collection<I> getItemsFromContainer(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart container, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from class:AbstractItemMergingServiceGets the from the item container.- Specified by:
getItemsFromContainerin classAbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>- Parameters:
container- the container to fetch the items fromcontext- the context of the request- Returns:
- the items from the container
-
isSameItem
protected boolean isSameItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item1, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item2)Description copied from class:AbstractItemMergingServiceTells if two item instances are actually the same instance. This would typically be determined by something like the item ID. Note that this does NOT indicate that "these items are the same so they should be merged". This is used to prevent creating an item match with itself during an update scenario.- Specified by:
isSameItemin classAbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>- Parameters:
item1- an item to compareitem2- another item to compare- Returns:
- true if the two items are referring to the same instance
-
hashMatchingCriteria
protected String hashMatchingCriteria(@NonNull I item)
Generates a hash for any information on the item that should be used to determine if they represent the same item configuration. This implementation only uses attribute choices, which are product options of type CART_ITEM_ATTRIBUTE or VARIANT_DISTINGUISHING.- Specified by:
hashMatchingCriteriain classAbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>- Parameters:
item- the item to generate a hash for- Returns:
- a hashed string of some subset of the items attributes
-
resolveMergeTypes
protected void resolveMergeTypes(@NonNull @NonNull List<MergeItemPair<I>> mergeItemPairs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Description copied from class:AbstractItemMergingServiceDetermines what merge types should be used for the items and applies it to the merge item pairs.- Specified by:
resolveMergeTypesin classAbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>- Parameters:
mergeItemPairs- the item pairs to resolve the merge types for
-
doMergeCombine
protected void doMergeCombine(@NonNull @NonNull MergeItemPair<I> itemPair)Description copied from class:AbstractItemMergingServicePerform the actual combination of two items (quantity change) for the combination merge type.- Specified by:
doMergeCombinein classAbstractItemMergingService<com.broadleafcommerce.cart.client.domain.Cart,I extends com.broadleafcommerce.cart.client.domain.CartItem>- Parameters:
itemPair- the item pair to combine
-
getProviders
protected CartOperationServiceProviders getProviders()
-
getProperties
protected CartOperationServiceProperties getProperties()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
-