Class CartDiscountReferenceResolver


  • public final class CartDiscountReferenceResolver
    extends CustomReferenceResolver<com.commercetools.api.models.cart_discount.CartDiscountDraft,​com.commercetools.api.models.cart_discount.CartDiscountDraftBuilder,​CartDiscountSyncOptions>
    • Constructor Detail

      • CartDiscountReferenceResolver

        public CartDiscountReferenceResolver​(@Nonnull
                                             CartDiscountSyncOptions options,
                                             @Nonnull
                                             TypeService typeService)
        Takes a CartDiscountSyncOptions instance, a TypeService to instantiate a CartDiscountReferenceResolver instance that could be used to resolve the cartDiscount drafts in the CTP project specified in the injected CartDiscountSyncOptions instance.
        Parameters:
        options - the container of all the options of the sync process including the CTP project client and/or configuration and other sync-specific options.
        typeService - the service to fetch the custom types for reference resolution.
    • Method Detail

      • resolveReferences

        @Nonnull
        public java.util.concurrent.CompletionStage<com.commercetools.api.models.cart_discount.CartDiscountDraft> resolveReferences​(@Nonnull
                                                                                                                                    com.commercetools.api.models.cart_discount.CartDiscountDraft draft)
        Given a CartDiscountDraft this method attempts to resolve the custom type reference to return a CompletionStage which contains a new instance of the draft with the resolved reference or, in case an error occurs during reference resolution, a ReferenceResolutionException.
        Specified by:
        resolveReferences in class BaseReferenceResolver<com.commercetools.api.models.cart_discount.CartDiscountDraft,​CartDiscountSyncOptions>
        Parameters:
        draft - the CartDiscountDraft to resolve its references.
        Returns:
        a CompletionStage that contains as a result a new CartDiscountDraft instance with resolved custom type reference or, in case an error occurs during reference resolution, a ReferenceResolutionException.
      • resolveCustomTypeReference

        protected java.util.concurrent.CompletionStage<com.commercetools.api.models.cart_discount.CartDiscountDraftBuilder> resolveCustomTypeReference​(@Nonnull
                                                                                                                                                       com.commercetools.api.models.cart_discount.CartDiscountDraftBuilder draftBuilder)
        Description copied from class: CustomReferenceResolver
        Given a draft of 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).

        Specified by:
        resolveCustomTypeReference in class CustomReferenceResolver<com.commercetools.api.models.cart_discount.CartDiscountDraft,​com.commercetools.api.models.cart_discount.CartDiscountDraftBuilder,​CartDiscountSyncOptions>
        Parameters:
        draftBuilder - the draft builder to resolve it's references.
        Returns:
        a 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.