Class BaseReferenceResolver<T,​S extends BaseSyncOptions>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BaseReferenceResolver​(S options)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected static <T> java.lang.String getIdFromReference​(io.sphere.sdk.models.Reference<T> reference)
      This method gets the key value on the passed Reference from the id field, if valid.
      protected static <T> java.lang.String getKeyFromResourceIdentifier​(io.sphere.sdk.models.ResourceIdentifier<T> resourceIdentifier)
      This method gets the key value on the passed ResourceIdentifier, if valid.
      abstract java.util.concurrent.CompletionStage<T> resolveReferences​(T 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • BaseReferenceResolver

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

      • resolveReferences

        public abstract java.util.concurrent.CompletionStage<T> resolveReferences​(@Nonnull
                                                                                  T 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
                                                                 io.sphere.sdk.models.Reference<T> 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 <T> java.lang.String getKeyFromResourceIdentifier​(@Nonnull
                                                                           io.sphere.sdk.models.ResourceIdentifier<T> 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.
        If the above checks pass, the key value is returned. Otherwise a ReferenceResolutionException is thrown.
        Type Parameters:
        T - the type of the reference.
        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.