public abstract class AbstractItemMergingService<C,I> extends Object implements ItemMergingService<C,I>
| Constructor and Description |
|---|
AbstractItemMergingService() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
doMergeCombine(MergeItemPair<I> itemPair)
Perform the actual combination of two items (quantity change) for the combination merge type.
|
protected List<MergeItemPair<I>> |
findMatchingItems(C container,
@NonNull Collection<I> itemsToAdd,
com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Finds matching items in the container to the collection of items.
|
protected List<MergeItemPair<I>> |
findMatchingItems(@NonNull Collection<I> containerItems,
@NonNull Collection<I> itemsToAdd)
Finds matching item pairs across the collections of items.
|
protected abstract Collection<I> |
getItemsFromContainer(C container,
com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Gets the from the item container.
|
protected void |
handleRejectedMerges(@NonNull List<I> items,
@NonNull List<MergeItemPair<I>> itemPairs)
Throws an exception when only one item is being added/updated and has a matching item.
|
protected abstract String |
hashMatchingCriteria(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 abstract boolean |
isSameItem(I item1,
I item2)
Tells if two item instances are actually the same instance.
|
protected void |
merge(@NonNull MergeItemPair<I> itemPair)
Merges the item pair using the merge type of the pair.
|
protected void |
mergeCombine(@NonNull MergeItemPair<I> itemPair)
Performs a "combination" merge for an item pair.
|
protected void |
mergeIgnore(@NonNull MergeItemPair<I> itemPair)
Performs a "reject or ignore" merge for an item pair.
|
List<MergeItemPair<I>> |
mergeItems(C container,
@NonNull List<I> itemsToAdd,
com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Determines and prepares item merges between items being added/modified and the items of the
container.
|
protected void |
mergeSeparate(@NonNull MergeItemPair<I> itemPair)
Performs a "separate" merge for an item pair.
|
protected abstract void |
resolveMergeTypes(@NonNull List<MergeItemPair<I>> itemPairs,
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.
|
public List<MergeItemPair<I>> mergeItems(@NonNull C container, @NonNull @NonNull List<I> itemsToAdd, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
ItemMergingServicemergeItems in interface ItemMergingService<C,I>container - the container that holds the items that will be merged.itemsToAdd - the items that have been changed or are being added to consider for mergingcontext - the context of the requestprotected List<MergeItemPair<I>> findMatchingItems(@NonNull C container, @NonNull @NonNull Collection<I> itemsToAdd, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
findMatchingItems(Collection, Collection) for more detail.container - the container holding items to compare againstitemsToAdd - the items to find matches inside the container forcontext - the context of the requestprotected abstract Collection<I> getItemsFromContainer(C container, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
container - the container to fetch the items fromcontext - the context of the requestprotected List<MergeItemPair<I>> findMatchingItems(@NonNull @NonNull Collection<I> containerItems, @NonNull @NonNull Collection<I> itemsToAdd)
containerItems - the items from the container to find matches foritemsToAdd - the items being manipulated (added/updated) to find matches forprotected abstract boolean isSameItem(I item1, I item2)
item1 - an item to compareitem2 - another item to compareprotected abstract String hashMatchingCriteria(I item)
item - the item to generate a hash forprotected abstract void resolveMergeTypes(@NonNull
@NonNull List<MergeItemPair<I>> itemPairs,
@Nullable
com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
itemPairs - the item pairs to resolve the merge types forprotected void merge(@NonNull
@NonNull MergeItemPair<I> itemPair)
itemPair - the item pair to perform a merge onprotected void mergeCombine(@NonNull
@NonNull MergeItemPair<I> itemPair)
itemPair - the item pair to mergeDefaultMergingType.COMBINEprotected void mergeSeparate(@NonNull
@NonNull MergeItemPair<I> itemPair)
itemPair - the item pair to mergeDefaultMergingType.SEPARATEprotected void mergeIgnore(@NonNull
@NonNull MergeItemPair<I> itemPair)
itemPair - the item pair to mergeDefaultMergingType.REJECT_OR_IGNOREprotected abstract void doMergeCombine(MergeItemPair<I> itemPair)
itemPair - the item pair to combineprotected void handleRejectedMerges(@NonNull
@NonNull List<I> items,
@NonNull
@NonNull List<MergeItemPair<I>> itemPairs)
DefaultMergingType.REJECT_OR_IGNORE).items - the items being added/updateditemPairs - the found item pairsCopyright © 2021. All rights reserved.