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

com.fasterxml.storemate.json.StorableKeyDeserializer Maven / Gradle / Ivy

Go to download

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

The newest version!
package com.fasterxml.storemate.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
{
    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(getValueClass(), jp.getCurrentToken());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy