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

com.fasterxml.clustermate.json.IpAndPortDeserializer Maven / Gradle / Ivy

Go to download

Converters for ClusterMate and StoreMate datatypes, for Jackson-based JSON serialization (as well as other dataformats Jackson supports, like Smile)

The newest version!
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
{
    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(IpAndPort.class, jp.getCurrentToken());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy