Package com.fasterxml.clustermate.json

Source Code of com.fasterxml.clustermate.json.StorableKeyDeserializer

package com.fasterxml.clustermate.json;

import java.io.IOException;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
import com.fasterxml.storemate.shared.StorableKey;

@SuppressWarnings("serial")
public class StorableKeyDeserializer extends StdScalarDeserializer<StorableKey>
{
    public StorableKeyDeserializer() {
        super(StorableKey.class);
    }

    @Override
    public StorableKey deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException
    {
        switch (jp.getCurrentToken()) {
        case VALUE_STRING:
        case VALUE_EMBEDDED_OBJECT:
            byte[] raw = jp.getBinaryValue();
            return new StorableKey(raw);
        default:
            throw ctxt.mappingException(StorableKey.class, jp.getCurrentToken());
        }
    }
}
TOP

Related Classes of com.fasterxml.clustermate.json.StorableKeyDeserializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.