Package com.xeiam.xchange.coinbase.dto.account

Source Code of com.xeiam.xchange.coinbase.dto.account.CoinbaseCategoryDeserializer

package com.xeiam.xchange.coinbase.dto.account;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.xeiam.xchange.coinbase.dto.account.CoinbaseAccountChangeCategory.CoinbaseCategoryDeserializer;
import com.xeiam.xchange.coinbase.dto.serialization.EnumFromStringHelper;
import com.xeiam.xchange.coinbase.dto.serialization.EnumLowercaseJsonSerializer;

/**
* @author jamespedwards42
*/
@JsonDeserialize(using = CoinbaseCategoryDeserializer.class)
@JsonSerialize(using = EnumLowercaseJsonSerializer.class)
public enum CoinbaseAccountChangeCategory {

  TX, REQUEST, TRANSFER, INVOICE;

  static class CoinbaseCategoryDeserializer extends JsonDeserializer<CoinbaseAccountChangeCategory> {

    private static final EnumFromStringHelper<CoinbaseAccountChangeCategory> FROM_STRING_HELPER = new EnumFromStringHelper<CoinbaseAccountChangeCategory>(CoinbaseAccountChangeCategory.class);

    @Override
    public CoinbaseAccountChangeCategory deserialize(final JsonParser jsonParser, final DeserializationContext ctxt) throws IOException, JsonProcessingException {

      final ObjectCodec oc = jsonParser.getCodec();
      final JsonNode node = oc.readTree(jsonParser);
      final String jsonString = node.textValue();
      return FROM_STRING_HELPER.fromJsonString(jsonString);
    }
  }
}
TOP

Related Classes of com.xeiam.xchange.coinbase.dto.account.CoinbaseCategoryDeserializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.