public final class SetImageLabel extends UpdateActionImpl<Product>
masterData
property of a Product
.
withProductWithImages(client(), Arrays.asList(URL_1), (Product product) -> { final String changeToImageLabel = "New image label"; final ProductUpdateCommand updateCommand = ProductUpdateCommand.of(product, SetImageLabel.of(1, URL_1, changeToImageLabel, null)); final Product updatedProduct = client().executeBlocking(updateCommand); final Optional<Image> changedImage = updatedProduct.getMasterData().getStaged().getMasterVariant().getImages() .stream() .findFirst(); assertThat(changedImage).isPresent(); final String updatedImageLabel = changedImage.get().getLabel(); assertThat(updatedImageLabel).isEqualTo(changeToImageLabel); return updatedProduct; });
See the test code.
ProductVariant.getImages()
,
Image.getLabel()
Modifier and Type | Method and Description |
---|---|
String |
getImageUrl() |
String |
getLabel() |
Integer |
getVariantId() |
Boolean |
isStaged() |
static SetImageLabel |
of(Integer variantId,
String imageUrl,
String label,
Boolean staged)
Creates a new update action initialized with the given values.
|
static SetImageLabel |
ofStaged(Integer variantId,
String imageUrl,
String label)
Creates a new update action initialized with the given values.
|
static SetImageLabel |
ofUnset(Integer variantId,
String imageUrl,
Boolean staged)
Creates a new update action initialized with the given values to unset the label.
|
static SetImageLabel |
ofUnsetStaged(Integer variantId,
String imageUrl)
Creates a new update action initialized with the given values to unset the staged label.
|
SetImageLabel |
withLabel(String label)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
SetImageLabel |
withStaged(Boolean staged)
Creates a copied update action initialized with the given parameter, the rest of the parameters are copied from the original object.
|
getAction
public Integer getVariantId()
public String getImageUrl()
public static SetImageLabel of(Integer variantId, String imageUrl, @Nullable String label, @Nullable Boolean staged)
variantId
- initial value for the propertyimageUrl
- initial value for the propertylabel
- initial value for the propertystaged
- initial value for the propertypublic static SetImageLabel ofStaged(Integer variantId, String imageUrl, @Nullable String label)
variantId
- initial value for the propertyimageUrl
- initial value for the propertylabel
- initial value for the propertypublic static SetImageLabel ofUnset(Integer variantId, String imageUrl, @Nullable Boolean staged)
variantId
- initial value for the propertyimageUrl
- initial value for the propertystaged
- initial value for the propertypublic static SetImageLabel ofUnsetStaged(Integer variantId, String imageUrl)
variantId
- initial value for the propertyimageUrl
- initial value for the propertypublic SetImageLabel withLabel(String label)
label
- The image label.public SetImageLabel withStaged(Boolean staged)
staged
- specifiy if image is staged