
io.sphere.sdk.products.ProductVariantImpl Maven / Gradle / Ivy
The newest version!
package io.sphere.sdk.products;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.sphere.sdk.json.JsonException;
import io.sphere.sdk.attributes.Attribute;
import io.sphere.sdk.attributes.AttributeMapper;
import io.sphere.sdk.models.Image;
import java.util.List;
import java.util.Optional;
import static java.lang.String.format;
class ProductVariantImpl extends AttributeContainerImpl implements ProductVariant {
private final int id;
private final Optional sku;
private final List prices;
private final List images;
private final Optional availability;
@JsonCreator
ProductVariantImpl(final int id, final Optional sku, final List prices,
final List attributes, final List images,
final Optional availability) {
super(attributes);
this.id = id;
this.sku = sku;
this.prices = prices;
this.images = images;
this.availability = availability;
}
@Override
public int getId() {
return id;
}
@Override
public Optional getSku() {
return sku;
}
@Override
public List getPrices() {
return prices;
}
@Override
public List getImages() {
return images;
}
@Override
public Optional getAvailability() {
return availability;
}
@Override
protected JsonException transformError(JsonException e, String attributeName, AttributeMapper> mapper) {
return enrich(format("ProductVariant(id=%s)", id), attributeName, mapper, e.getCause());
}
private JsonException enrich(final Object objectWithAttributes, final String attributeName, final AttributeMapper> mapper, final Throwable cause) {
return new JsonException(format("%s does not contain an attribute '%s' which can be mapped with %s.", objectWithAttributes, attributeName, mapper), cause);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy