Package com.fasterxml.clustermate.json

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

package com.fasterxml.clustermate.json;

import java.io.IOException;

import com.fasterxml.clustermate.api.KeySpace;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;


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

    @Override
    public KeySpace deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException
    {
        switch (jp.getCurrentToken()) {
        case VALUE_STRING:
            int i = jp.getValueAsInt(-1);
            if (i > 0) {
                return new KeySpace(jp.getValueAsInt());
            }
            break;
        case VALUE_NUMBER_INT:
            return new KeySpace(jp.getIntValue());
        default:
        }
        throw ctxt.mappingException(KeySpace.class, jp.getCurrentToken());
    }
}
TOP

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

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.