org.knowm.xchange.bitmex.dto.trade.BitmexTickDirection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xchange-bitmex Show documentation
Show all versions of xchange-bitmex Show documentation
XChange implementations for the BitMex Exchange.
The newest version!
package org.knowm.xchange.bitmex.dto.trade;
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 java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.knowm.xchange.bitmex.dto.trade.BitmexTickDirection.BitmexTickDirectionDeserializer;
@JsonDeserialize(using = BitmexTickDirectionDeserializer.class)
public enum BitmexTickDirection {
MINUSTICK,
PLUSTICK,
ZEROPLUSTICK;
private static final Map fromString = new HashMap<>();
static {
for (BitmexTickDirection tickDirection : values())
fromString.put(tickDirection.toString(), tickDirection);
}
public static BitmexTickDirection fromString(String tickDirectionString) {
return fromString.get(tickDirectionString.toLowerCase());
}
@Override
public String toString() {
return super.toString().toLowerCase();
}
static class BitmexTickDirectionDeserializer extends JsonDeserializer {
@Override
public BitmexTickDirection deserialize(JsonParser jsonParser, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
String tickDirectionString = node.textValue();
return fromString(tickDirectionString);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy