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

com.azure.cosmos.implementation.ItemDeserializer Maven / Gradle / Ivy

Go to download

This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API

There is a newer version: 4.61.1
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.implementation;

import com.fasterxml.jackson.databind.node.ObjectNode;


public interface ItemDeserializer {
     T parseFrom(Class classType, byte[] bytes);
     T convert(Class classType, ObjectNode objectNode);


    class JsonDeserializer implements ItemDeserializer {
        public  T parseFrom(Class classType, byte[] bytes) {
            if (bytes == null) {
                return null;
            }

            // TODO: does this handdle jackson ObjectNode?
            return Utils.parse(bytes, classType);
        }

        @Override
        @SuppressWarnings("unchecked")
        public  T convert(Class classType, ObjectNode objectNode) {
            if (classType == ObjectNode.class) {
                return (T) objectNode;
            }

            return Utils.getSimpleObjectMapper().convertValue(objectNode, classType);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy