public final class ProductVariantAttributeUpdateActionUtils
extends java.lang.Object
| Constructor and Description |
|---|
ProductVariantAttributeUpdateActionUtils() |
| Modifier and Type | Method and 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,
AttributeMetaData attributeMetaData)
Compares the attributes of a
AttributeDraft and a Attribute to build either a
SetAttribute or a
SetAttributeInAllVariants. |
public ProductVariantAttributeUpdateActionUtils()
@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,
@Nullable
AttributeMetaData attributeMetaData)
throws BuildUpdateActionException
AttributeDraft and a Attribute to build either a
SetAttribute or a
SetAttributeInAllVariants.
If the attribute is sameForAll a
SetAttributeInAllVariants is built. Otherwise,
a SetAttribute is built.
If both the AttributeDraft and the Attribute have identical values, then
no update action is needed and hence an empty List is returned.
variantId - the id of the variant of that the attribute belong to. It is used only in the error
messages if any.oldProductVariantAttribute - the Attribute which should be updated.newProductVariantAttribute - the AttributeDraft where we get the new value.attributeMetaData - a map of attribute name -> AttributeMetaData; which defines attribute
information: its name, whether a value is required or not and whether it has the
constraint "SameForAll" or not.BuildUpdateActionException - thrown if attribute as not found in the attributeMetaData or
if the attribute is required and the new value is null.