Class BaseReferenceResolver<ResourceDraftT extends io.vrap.rmf.base.client.Draft<ResourceDraftT>,​SyncOptionsT extends BaseSyncOptions>

    • Field Detail

      • BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER

        public static final java.lang.String BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER
        See Also:
        Constant Field Values
      • BLANK_ID_VALUE_ON_REFERENCE

        public static final java.lang.String BLANK_ID_VALUE_ON_REFERENCE
        See Also:
        Constant Field Values
      • SELF_REFERENCING_ID_PLACE_HOLDER

        public static final java.lang.String SELF_REFERENCING_ID_PLACE_HOLDER
        See Also:
        Constant Field Values
    • Constructor Detail

      • BaseReferenceResolver

        protected BaseReferenceResolver​(@Nonnull
                                        SyncOptionsT options)
    • Method Detail

      • resolveReferences

        public abstract java.util.concurrent.CompletionStage<ResourceDraftT> resolveReferences​(@Nonnull
                                                                                               ResourceDraftT draft)
        Given a draft this method attempts to resolve the all the references on the draft to return a CompletionStage which contains a new instance of the draft with the resolved references.
        Parameters:
        draft - the productDraft to resolve it's references.
        Returns:
        a CompletionStage that contains as a result a new draft instance with resolved references or, in case an error occurs during reference resolution, a ReferenceResolutionException.
      • getIdFromReference

        @Nonnull
        protected static <T> java.lang.String getIdFromReference​(@Nonnull
                                                                 com.commercetools.api.models.common.Reference reference)
                                                          throws ReferenceResolutionException
        This method gets the key value on the passed Reference from the id field, if valid. If it is not valid, a ReferenceResolutionException will be thrown. The validity checks are:
        • Checks if the id value is not null or not empty.
        If the above checks pass, the key value is returned. Otherwise a ReferenceResolutionException is thrown.
        Type Parameters:
        T - the type of the reference.
        Parameters:
        reference - the reference from which the key value is validated and returned.
        Returns:
        the Id value on the ResourceIdentifier
        Throws:
        ReferenceResolutionException - if any of the validation checks fail.
      • getKeyFromResourceIdentifier

        @Nonnull
        protected static java.lang.String getKeyFromResourceIdentifier​(@Nonnull
                                                                       com.commercetools.api.models.common.ResourceIdentifier resourceIdentifier)
                                                                throws ReferenceResolutionException
        This method gets the key value on the passed ResourceIdentifier, if valid. If it is not valid, a ReferenceResolutionException will be thrown. The validity checks are:
        • Checks if the key value is not null or not empty.
        • Checks if the key value is not equal to KEY_IS_NOT_SET(fetched from cache).
        If the above checks pass, the key value is returned. Otherwise a ReferenceResolutionException is thrown.
        Parameters:
        resourceIdentifier - the resource identifier from which the key value is validated and returned.
        Returns:
        the key value on the ResourceIdentifier
        Throws:
        ReferenceResolutionException - if any of the validation checks fail.