Refine search
@Override public KrakenPublicOrder deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node.isArray()) { BigDecimal price = new BigDecimal(node.path(0).asText()); BigDecimal volume = new BigDecimal(node.path(1).asText()); long timestamp = node.path(2).asLong(); return new KrakenPublicOrder(price, volume, timestamp); } return null; } }
public Set<NodeFileDescriptorStats> getFileDescriptorStats() { final JsonNode nodes = catNodes("name", "host", "ip", "fileDescriptorMax"); final ImmutableSet.Builder<NodeFileDescriptorStats> setBuilder = ImmutableSet.builder(); for (JsonNode jsonElement : nodes) { if (jsonElement.isObject()) { final String name = jsonElement.path("name").asText(); final String host = jsonElement.path("host").asText(null); final String ip = jsonElement.path("ip").asText(); final JsonNode fileDescriptorMax = jsonElement.path("fileDescriptorMax"); final Long maxFileDescriptors = fileDescriptorMax.isLong() ? fileDescriptorMax.asLong() : null; setBuilder.add(NodeFileDescriptorStats.create(name, ip, host, maxFileDescriptors)); } } return setBuilder.build(); }
private static Object extractSingleValue(JsonNode jsonValue, FieldSpec.DataType dataType) { Preconditions.checkArgument(jsonValue.isValueNode()); switch (dataType) { case INT: return jsonValue.asInt(); case LONG: return jsonValue.asLong(); case FLOAT: return (float) jsonValue.asDouble(); case DOUBLE: return jsonValue.asDouble(); case STRING: return jsonValue.asText(); default: throw new IllegalArgumentException(); } } }
protected void setOutcomeConditionExpression(SequenceFlow flow, JsonNode expressionNode) { Long formId = null; if (expressionNode.get("outcomeFormId") != null && !(expressionNode.get("outcomeFormId").isNull())) { formId = expressionNode.get("outcomeFormId").asLong(); } String operator = null; if (expressionNode.get("operator") != null && expressionNode.get("operator").isNull() == false) { operator = expressionNode.get("operator").asText(); } String outcomeName = null; if (expressionNode.get("outcomeName") != null && !(expressionNode.get("outcomeName").isNull())) { outcomeName = expressionNode.get("outcomeName").asText(); } if (formId != null && operator != null && outcomeName != null) { flow.setConditionExpression("${form" + formId + "outcome " + operator + " " + outcomeName + "}"); addExtensionElement("conditionFormId", String.valueOf(formId), flow); addExtensionElement("conditionOperator", operator, flow); addExtensionElement("conditionOutcomeName", outcomeName, flow); } }
@Override public KrakenSpreads deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { List<KrakenSpread> krakenTrades = new ArrayList<>(); long last = 0; ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); Iterator<Entry<String, JsonNode>> tradesResultIterator = node.fields(); while (tradesResultIterator.hasNext()) { Entry<String, JsonNode> entry = tradesResultIterator.next(); String key = entry.getKey(); JsonNode value = entry.getValue(); if (key == "last") { last = value.asLong(); } else if (value.isArray()) { for (JsonNode jsonSpreadNode : value) { long time = jsonSpreadNode.path(0).asLong(); BigDecimal bid = new BigDecimal(jsonSpreadNode.path(1).asText()); BigDecimal ask = new BigDecimal(jsonSpreadNode.path(2).asText()); krakenTrades.add(new KrakenSpread(time, bid, ask)); } } } return new KrakenSpreads(krakenTrades, last); } }
@Nullable private Object valueNode(JsonNode jsonNode) { if (jsonNode.isInt()) { return jsonNode.asInt(); } else if (jsonNode.isLong()) { return jsonNode.asLong(); } else if (jsonNode.isIntegralNumber()) { return jsonNode.asLong(); } else if (jsonNode.isFloatingPointNumber()) { return jsonNode.asDouble(); } else if (jsonNode.isBoolean()) { return jsonNode.asBoolean(); } else if (jsonNode.isNull()) { return null; } else { return jsonNode.asText(); } }
@Override Map<String, Object> userFromResource(String externalToken) { MultivaluedMap<String, String> formData = getMultivaluedMapImpl(); formData.add("grant_type", "urn:pingidentity.com:oauth2:grant_type:validate_bearer"); formData.add("client_id", clientId); formData.add("client_secret", clientSecret); formData.add("token", externalToken); JsonNode node = client.target(apiUrl).request() .post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE), JsonNode.class); String rawEmail = node.get("access_token").get("subject").asText(); Map<String, Object> userMap = new HashMap<String, Object>(); userMap.put("expiration", node.get("expires_in").asLong()); userMap.put("username", pingUsernameFrom(rawEmail)); userMap.put("name", "pinguser"); userMap.put("email", rawEmail); return userMap; }
last = value.asLong(); } else if (value.isArray()) { for (JsonNode jsonSpreadNode : value) { long time = jsonSpreadNode.path(0).asLong(); BigDecimal open = new BigDecimal(jsonSpreadNode.path(1).asText()); BigDecimal high = new BigDecimal(jsonSpreadNode.path(2).asText()); BigDecimal low = new BigDecimal(jsonSpreadNode.path(3).asText()); BigDecimal close = new BigDecimal(jsonSpreadNode.path(4).asText()); BigDecimal vwap = new BigDecimal(jsonSpreadNode.path(5).asText()); BigDecimal volume = new BigDecimal(jsonSpreadNode.path(6).asText()); long count = jsonSpreadNode.path(7).asLong(); krakenOHLCs.add(new KrakenOHLC(time, open, high, low, close, vwap, volume, count));
@Override public ColumnDef deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = jp.getCodec().readTree(jp); String type = node.get("type").asText(); String name = node.get("name").asText(); String charset = node.path("charset").asText(); boolean signed = node.path("signed").asBoolean(false); String[] enumValues = null; JsonNode enumValueNode = node.get("enum-values"); if ( enumValueNode != null ) { ArrayList<String> values = new ArrayList<>(); for ( JsonNode n : enumValueNode ) values.add(n.asText()); enumValues = (String[]) values.toArray(new String[0]); } Long columnLength = null; JsonNode columnLengthNode = node.get("column-length"); if ( columnLengthNode != null ) { columnLength = columnLengthNode.asLong(); } return ColumnDef.build(name, charset, type, (short) 0, signed, enumValues, columnLength); } }
timestamp = node.asLong(); } else if (key.equalsIgnoreCase("username")) { username = node.asText(); } else if (key.equalsIgnoreCase("error")) { error = node.asText(); } else if (node.isObject()) { BigDecimal available = node.has("available") ? new BigDecimal(node.get("available").asText()) : null; BigDecimal orders = node.has("orders") ? new BigDecimal(node.get("orders").asText()) : null;
@Override public KucoinActiveOrder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode root = p.readValueAsTree(); if (root.isArray()) { Date timestamp = new Date(root.get(0).asLong()); KucoinOrderType orderType = KucoinOrderType.valueOf(root.get(1).asText()); BigDecimal price = root.get(2).decimalValue(); BigDecimal amount = root.get(3).decimalValue(); BigDecimal dealAmount = root.get(4).decimalValue(); // amount already filled String orderOid = root.get(5).textValue(); return new KucoinActiveOrder(timestamp, orderType, price, amount, dealAmount, orderOid); } else { throw new RuntimeException("KucoinDealOrder should have an array as root node!"); } } }
@Override public KrakenPublicTrades deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { List<KrakenPublicTrade> krakenTrades = new ArrayList<>(); long last = 0; ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); Iterator<Entry<String, JsonNode>> tradesResultIterator = node.fields(); while (tradesResultIterator.hasNext()) { Entry<String, JsonNode> entry = tradesResultIterator.next(); String key = entry.getKey(); JsonNode value = entry.getValue(); if (key == "last") { last = value.asLong(); } else if (value.isArray()) { for (JsonNode tradeJsonNode : value) { BigDecimal price = new BigDecimal(tradeJsonNode.path(0).asText()); BigDecimal volume = new BigDecimal(tradeJsonNode.path(1).asText()); double time = tradeJsonNode.path(2).asDouble(); KrakenType type = KrakenType.fromString(tradeJsonNode.path(3).asText()); KrakenOrderType orderType = KrakenOrderType.fromString(tradeJsonNode.path(4).asText()); String miscellaneous = tradeJsonNode.path(5).asText(); krakenTrades.add( new KrakenPublicTrade(price, volume, time, type, orderType, miscellaneous)); } } } return new KrakenPublicTrades(krakenTrades, last); } }
String id = node.get("id").asText(); String name = node.get("name").asText(); String symbol = node.get("symbol").asText(); String websiteSlug = node.get("website_slug").asText(); Date lastUpdated = new Date(node.get("last_updated").asLong() * 1000); BigDecimal rank = new BigDecimal(node.get("rank").asInt()); BigDecimal circulatingSupply = new BigDecimal(node.get("circulating_supply").asDouble());
final String errorText = errorNode.asText(); if (errorText.equals("Invalid symbols pair")) { return new CexIOOpenOrders(); if (openOrdersNode.isArray()) { for (JsonNode openOrderNode : openOrdersNode) { final long id = openOrderNode.path("id").asLong(); final long time = openOrderNode.path("time").asLong(); final Type type = Type.valueOf(openOrderNode.path("type").asText()); final BigDecimal price = new BigDecimal(openOrderNode.path("price").asText()); final BigDecimal amount = new BigDecimal(openOrderNode.path("amount").asText()); final BigDecimal pending = new BigDecimal(openOrderNode.path("pending").asText());
@Override public KucoinDealOrder deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode root = p.readValueAsTree(); if (root.isArray()) { Long timestamp = root.get(0).asLong(); KucoinOrderType orderType = KucoinOrderType.valueOf(root.get(1).asText()); BigDecimal price = root.get(2).decimalValue(); BigDecimal amount = root.get(3).decimalValue(); BigDecimal volume = root.get(4).decimalValue(); return new KucoinDealOrder(timestamp, orderType, price, amount, volume); } else { throw new RuntimeException("KucoinDealOrder should have an array as root node!"); } } }
@Override public RedisStateMap deserialize(final byte[] data) throws IOException { if (data == null || data.length == 0) { return null; } final RedisStateMap.Builder builder = new RedisStateMap.Builder(); try (final JsonParser jsonParser = jsonFactory.createParser(data)) { final JsonNode rootNode = jsonParser.readValueAsTree(); builder.version(rootNode.get(FIELD_VERSION).asLong()); builder.encodingVersion(rootNode.get(FIELD_ENCODING).asInt()); final JsonNode stateValuesNode = rootNode.get(FIELD_STATE_VALUES); stateValuesNode.fields().forEachRemaining(e -> builder.stateValue(e.getKey(), e.getValue().asText())); } return builder.build(); }