com.azure.cosmos.implementation.ItemDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-cosmos Show documentation
Show all versions of azure-cosmos Show documentation
This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API
// 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);
}
}
}