Class ProductVariantAttributeUpdateActionUtils
- java.lang.Object
 - 
- com.commercetools.sync.products.utils.ProductVariantAttributeUpdateActionUtils
 
 
- 
public final class ProductVariantAttributeUpdateActionUtils extends java.lang.Object 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTRIBUTE_NOT_IN_ATTRIBUTE_METADATA 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>>buildProductVariantAttributeUpdateAction(int variantId, io.sphere.sdk.products.attributes.Attribute oldProductVariantAttribute, io.sphere.sdk.products.attributes.AttributeDraft newProductVariantAttribute, java.util.Map<java.lang.String,AttributeMetaData> attributesMetaData)Compares the attributes of aAttributeDraftand aAttributeto build either aSetAttributeor aSetAttributeInAllVariants. 
 - 
 
- 
- 
Field Detail
- 
ATTRIBUTE_NOT_IN_ATTRIBUTE_METADATA
public static final java.lang.String ATTRIBUTE_NOT_IN_ATTRIBUTE_METADATA
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
buildProductVariantAttributeUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildProductVariantAttributeUpdateAction(int variantId, @Nullable io.sphere.sdk.products.attributes.Attribute oldProductVariantAttribute, @Nonnull io.sphere.sdk.products.attributes.AttributeDraft newProductVariantAttribute, @Nonnull java.util.Map<java.lang.String,AttributeMetaData> attributesMetaData) throws BuildUpdateActionExceptionCompares the attributes of aAttributeDraftand aAttributeto build either aSetAttributeor aSetAttributeInAllVariants.If the attribute is sameForAll a
SetAttributeInAllVariantsis built. Otherwise, aSetAttributeis built.If both the
AttributeDraftand theAttributehave identical values, then no update action is needed and hence an emptyListis returned.- Parameters:
 variantId- the id of the variant of that the attribute belong to. It is used only in the error messages if any.oldProductVariantAttribute- theAttributewhich should be updated.newProductVariantAttribute- theAttributeDraftwhere we get the new value.attributesMetaData- a map of attribute name ->AttributeMetaData; which defines attribute information: its name and whether it has the constraint "SameForAll" or not.- Returns:
 - A filled optional with the update action or an empty optional if the attributes are identical.
 - Throws:
 BuildUpdateActionException- thrown if attribute as not found in theattributeMetaDataor if the attribute is required and the new value is null.
 
 - 
 
 -