Class ProductTypeBatchValidator
- java.lang.Object
-
- com.commercetools.sync.commons.helpers.BaseBatchValidator<io.sphere.sdk.producttypes.ProductTypeDraft,ProductTypeSyncOptions,ProductTypeSyncStatistics>
-
- com.commercetools.sync.producttypes.helpers.ProductTypeBatchValidator
-
public class ProductTypeBatchValidator extends BaseBatchValidator<io.sphere.sdk.producttypes.ProductTypeDraft,ProductTypeSyncOptions,ProductTypeSyncStatistics>
-
-
Constructor Summary
Constructors Constructor Description ProductTypeBatchValidator(ProductTypeSyncOptions syncOptions, ProductTypeSyncStatistics syncStatistics)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<java.lang.String>getProductTypeKey(io.sphere.sdk.products.attributes.AttributeType attributeType)This method is meant be only used internally by the library.org.apache.commons.lang3.tuple.ImmutablePair<java.util.Set<io.sphere.sdk.producttypes.ProductTypeDraft>,java.util.Set<java.lang.String>>validateAndCollectReferencedKeys(java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> productTypeDrafts)Given theList<ProductTypeDraft> of drafts this method attempts to validate drafts and collect referenced keys from the draft and return anImmutablePair<Set<ProductTypeDraft> ,Set<String>> which contains theSetof valid drafts and referenced product type keys.-
Methods inherited from class com.commercetools.sync.commons.helpers.BaseBatchValidator
collectReferencedKeyFromCustomFieldsDraft, collectReferencedKeyFromReference, collectReferencedKeyFromResourceIdentifier, collectReferencedKeysFromAssetDrafts, handleError, handleError
-
-
-
-
Constructor Detail
-
ProductTypeBatchValidator
public ProductTypeBatchValidator(@Nonnull ProductTypeSyncOptions syncOptions, @Nonnull ProductTypeSyncStatistics syncStatistics)
-
-
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 theList<ProductTypeDraft> of drafts this method attempts to validate drafts and collect referenced keys from the draft and return anImmutablePair<Set<ProductTypeDraft> ,Set<String>> which contains theSetof valid drafts and referenced product type keys.A valid productType draft is one which satisfies the following conditions:
- It is not null
- It has a key which is not blank (null/empty)
- 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:
validateAndCollectReferencedKeysin classBaseBatchValidator<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 theSetof 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 InvalidReferenceExceptionThis 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.
-
-