io.sphere.sdk.products.attributes.NestedAttributeMapperImpl Maven / Gradle / Ivy
package io.sphere.sdk.products.attributes;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import io.sphere.sdk.json.JsonException;
import io.sphere.sdk.products.AttributeContainer;
import java.io.IOException;
import java.util.List;
class NestedAttributeMapperImpl extends AttributeMapperImpl {
NestedAttributeMapperImpl() {
super(new TypeReference() {});
}
@Override
public AttributeContainer deserialize(JsonNode value) {
try {
return AttributeContainer.of(mapper().readerFor(new TypeReference>() {}).readValue(value));
} catch (final IOException e) {
throw new JsonException(e);
}
}
@Override
public JsonNode serialize(final AttributeContainer attributeContainer) {
return mapper().valueToTree(attributeContainer.getAttributes());
}
}