Class ProductTypeBatchValidator
- java.lang.Object
-
- com.commercetools.sync.commons.helpers.BaseBatchValidator<com.commercetools.api.models.product_type.ProductTypeDraft,ProductTypeSyncOptions,ProductTypeSyncStatistics>
-
- com.commercetools.sync.producttypes.helpers.ProductTypeBatchValidator
-
public class ProductTypeBatchValidator extends BaseBatchValidator<com.commercetools.api.models.product_type.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(com.commercetools.api.models.product_type.AttributeType attributeType)
This method is meant be only used internally by the library.org.apache.commons.lang3.tuple.ImmutablePair<java.util.Set<com.commercetools.api.models.product_type.ProductTypeDraft>,java.util.Set<java.lang.String>>
validateAndCollectReferencedKeys(java.util.List<com.commercetools.api.models.product_type.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 theSet
of valid drafts and referenced product type keys.-
Methods inherited from class com.commercetools.sync.commons.helpers.BaseBatchValidator
collectReferencedKeyFromCustomFieldsDraft, 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<com.commercetools.api.models.product_type.ProductTypeDraft>,java.util.Set<java.lang.String>> validateAndCollectReferencedKeys(@Nonnull java.util.List<com.commercetools.api.models.product_type.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 theSet
of 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:
validateAndCollectReferencedKeys
in classBaseBatchValidator<com.commercetools.api.models.product_type.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 theSet
of valid drafts and referenced product type keys.
-
getProductTypeKey
@Nonnull public static java.util.Optional<java.lang.String> getProductTypeKey(@Nonnull com.commercetools.api.models.product_type.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.
-
-