public final class ShoppingListReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.shoppinglists.ShoppingListDraft,io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder,ShoppingListSyncOptions>
TYPE_DOES_NOT_EXIST
BLANK_ID_VALUE_ON_REFERENCE, BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER, options
Constructor and Description |
---|
ShoppingListReferenceResolver(ShoppingListSyncOptions shoppingListSyncOptions,
CustomerService customerService,
TypeService typeService)
Takes a
ShoppingListSyncOptions instance, a CustomerService and TypeService to instantiate a ShoppingListReferenceResolver instance that could be used
to resolve the shopping list drafts in the CTP project specified in the injected ShoppingListSyncOptions instance. |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> |
populateKeyToIdCachesForReferencedKeys(ShoppingListBatchValidator.ReferencedKeys referencedKeys)
Calls the
cacheKeysToIds service methods to fetch all the referenced keys (i.e custom
type, customer) from the CTP to populate caches for the reference resolution. |
protected java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder> |
resolveCustomerReference(io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder draftBuilder) |
protected java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder> |
resolveCustomTypeReference(io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder draftBuilder)
Given a draft of
D (e.g. |
java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraft> |
resolveReferences(io.sphere.sdk.shoppinglists.ShoppingListDraft shoppingListDraft)
Given a
ShoppingListDraft this method attempts to resolve the customer and custom type
references to return a CompletionStage which contains a new instance of the draft with
the resolved references. |
resolveCustomTypeReference
getIdFromReference, getKeyFromResourceIdentifier
public ShoppingListReferenceResolver(@Nonnull ShoppingListSyncOptions shoppingListSyncOptions, @Nonnull CustomerService customerService, @Nonnull TypeService typeService)
ShoppingListSyncOptions
instance, a CustomerService
and TypeService
to instantiate a ShoppingListReferenceResolver
instance that could be used
to resolve the shopping list drafts in the CTP project specified in the injected ShoppingListSyncOptions
instance.shoppingListSyncOptions
- the container of all the options of the sync process including
the CTP project client and/or configuration and other sync-specific options.customerService
- the service to fetch the customers for reference resolution.typeService
- the service to fetch the types for reference resolution.@Nonnull public java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraft> resolveReferences(@Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraft shoppingListDraft)
ShoppingListDraft
this method attempts to resolve the customer and custom type
references to return a CompletionStage
which contains a new instance of the draft with
the resolved references.resolveReferences
in class BaseReferenceResolver<io.sphere.sdk.shoppinglists.ShoppingListDraft,ShoppingListSyncOptions>
shoppingListDraft
- the shoppingListDraft to resolve its references.CompletionStage
that contains as a result a new shoppingListDraft instance
with resolved references or, in case an error occurs during reference resolution, a ReferenceResolutionException
.@Nonnull protected java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder> resolveCustomerReference(@Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder draftBuilder)
@Nonnull protected java.util.concurrent.CompletionStage<io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder> resolveCustomTypeReference(@Nonnull io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder draftBuilder)
CustomReferenceResolver
D
(e.g. CategoryDraft
) this method attempts to resolve it's
custom type reference to return CompletionStage
which contains a new instance of the
draft with the resolved custom type reference.
The method then tries to fetch the key of the custom type, optimistically from a cache. If the key is is not found, the resultant draft would remain exactly the same as the passed draft (without a custom type reference resolution).
resolveCustomTypeReference
in class CustomReferenceResolver<io.sphere.sdk.shoppinglists.ShoppingListDraft,io.sphere.sdk.shoppinglists.ShoppingListDraftBuilder,ShoppingListSyncOptions>
draftBuilder
- the draft builder to resolve it's references.CompletionStage
that contains as a result a new draft instance with resolved
custom type references or, in case an error occurs during reference resolution, a ReferenceResolutionException
.@Nonnull public java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> populateKeyToIdCachesForReferencedKeys(@Nonnull ShoppingListBatchValidator.ReferencedKeys referencedKeys)
cacheKeysToIds
service methods to fetch all the referenced keys (i.e custom
type, customer) from the CTP to populate caches for the reference resolution.
Note: This method is only to be used internally by the library to improve performance.
referencedKeys
- a wrapper for the custom type and customer references to fetch the keys,
and store the corresponding keys -> ids into cached maps.CompletionStage
<Map
<String
>String
>> in
which the results of its completions contains a map of requested references keys -> ids
of customer references.