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

com.unzer.payment.communication.JsonCurrencyConverter Maven / Gradle / Ivy

package com.unzer.payment.communication;

import com.google.gson.*;

import java.lang.reflect.Type;
import java.util.Currency;

public class JsonCurrencyConverter
        implements JsonDeserializer, JsonSerializer {

    @Override
    public Currency deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
        return Currency.getInstance(json.getAsJsonPrimitive().getAsString());
    }

    @Override
    public JsonElement serialize(Currency src, Type typeOfSrc, JsonSerializationContext context) {
        return new JsonPrimitive(src.getCurrencyCode());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy