Package com.fasterxml.clustermate.json

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

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.IpAndPort;

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

    @Override
    public IpAndPort deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException
    {
        switch (jp.getCurrentToken()) {
        // should we support anything other than Strings?
        case VALUE_STRING:
            return new IpAndPort(jp.getText());
        default:
          throw ctxt.mappingException(getValueClass(), jp.getCurrentToken());
        }
    }
}
TOP

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

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.