All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.products.attributes.NestedAttributeMapperImpl Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy