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

com.coinbase.api.deserializer.CurrencyUnitDeserializer Maven / Gradle / Ivy

The newest version!
package com.coinbase.api.deserializer;

import java.io.IOException;

import org.joda.money.CurrencyUnit;
import org.joda.money.IllegalCurrencyException;
import org.joda.time.DateTime;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

public class CurrencyUnitDeserializer extends StdDeserializer {

    public CurrencyUnitDeserializer() {
	super(CurrencyUnit.class);
    }

    @Override
    public CurrencyUnit deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
	    JsonProcessingException {
	
	CurrencyUnit result = null;
	try {
	    result = CurrencyUnit.getInstance(jp.getText());
	} catch (IllegalCurrencyException ex) {}
	
	return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy