Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.json;
 
 
We don't absolutely need a serializer for this type, but it's simple enough to do so.
public class KeyRangeSerializer extends StdSerializer<KeyRange>
    public KeyRangeSerializer() { super(KeyRange.class); }
    @Override
    public void serialize(KeyRange valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        jgen.writeStartObject();
        _serialize(valuejgenprovider);
        jgen.writeEndObject();
    }
    @Override
    public void serializeWithType(KeyRange valueJsonGenerator jgen,
            SerializerProvider providerTypeSerializer typeSer)
                    throws IOExceptionJsonProcessingException
    {
        typeSer.writeTypePrefixForObject(valuejgen);
        _serialize(valuejgenprovider);
        typeSer.writeTypeSuffixForObject(valuejgen);
    }
    protected void _serialize(KeyRange valueJsonGenerator jgenSerializerProvider provider)
        throws IOExceptionJsonGenerationException
    {
        jgen.writeNumberField("keyspace"value.getKeyspace().getLength());
        jgen.writeNumberField("start"value.getStart());
        jgen.writeNumberField("length"value.getLength());
    }
New to GrepCode? Check out our FAQ X