Class ProductTypeBatchValidator

    • Method Detail

      • validateAndCollectReferencedKeys

        public org.apache.commons.lang3.tuple.ImmutablePair<java.util.Set<io.sphere.sdk.producttypes.ProductTypeDraft>,​java.util.Set<java.lang.String>> validateAndCollectReferencedKeys​(@Nonnull
                                                                                                                                                                                               java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> productTypeDrafts)
        Given the List<ProductTypeDraft> of drafts this method attempts to validate drafts and collect referenced keys from the draft and return an ImmutablePair<Set<ProductTypeDraft> ,Set<String>> which contains the Set of valid drafts and referenced product type keys.

        A valid productType draft is one which satisfies the following conditions:

        1. It is not null
        2. It has a key which is not blank (null/empty)
        3. It has no invalid productType reference on an attributeDefinitionDraft with either a NestedType or SetType AttributeType. A valid reference is simply one which has its id field's value not blank (null/empty)
        Specified by:
        validateAndCollectReferencedKeys in class BaseBatchValidator<io.sphere.sdk.producttypes.ProductTypeDraft,​ProductTypeSyncOptions,​ProductTypeSyncStatistics>
        Parameters:
        productTypeDrafts - the product type drafts to validate and collect referenced product type keys.
        Returns:
        ImmutablePair<Set<ProductTypeDraft>, Set<String>> which contains the Set of valid drafts and referenced product type keys.
      • getProductTypeKey

        @Nonnull
        public static java.util.Optional<java.lang.String> getProductTypeKey​(@Nonnull
                                                                             io.sphere.sdk.products.attributes.AttributeType attributeType)
                                                                      throws InvalidReferenceException
        This method is meant be only used internally by the library.
        Parameters:
        attributeType - the attributeType to attempt to fetch the product type key of, if it contains a nestedType reference.
        Returns:
        an optional containing the productType key or empty if it does not contain a productType reference.
        Throws:
        InvalidReferenceException - thrown if the productType key in the nested reference is invalid.