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(); }
@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(); } }
if (val.isInt() || val.isLong()) { return val.asLong();
/** * Returns the JType for an integer field. Handles type lookup and unboxing. */ private JType getIntegerType(JCodeModel owner, JsonNode node, GenerationConfig config) { if (config.isUseBigIntegers()) { return unboxIfNecessary(owner.ref(BigInteger.class), config); } else if (config.isUseLongIntegers() || node.has("minimum") && node.get("minimum").isLong() || node.has("maximum") && node.get("maximum").isLong()) { return unboxIfNecessary(owner.ref(Long.class), config); } else { return unboxIfNecessary(owner.ref(Integer.class), config); } }
if (resultNode.isBoolean()) { result = resultNode.asBoolean(); } else if (resultNode.isLong()) { result = resultNode.asLong(); } else if (resultNode.isBigDecimal() || resultNode.isDouble()) {
} else if (valueType == ValueType.INTEGER && value.isInt()) { return ValueReference.of(value.intValue()); } else if (valueType == ValueType.LONG && (value.isLong() || value.isInt())) {
@Override public PathDetail deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonNode pathDetail = jp.readValueAsTree(); if (pathDetail.size() != 3) throw new JsonParseException(jp, "PathDetail array must have exactly 3 entries but was " + pathDetail.size()); JsonNode from = pathDetail.get(0); JsonNode to = pathDetail.get(1); JsonNode val = pathDetail.get(2); PathDetail pd; if (val.isBoolean()) pd = new PathDetail(val.asBoolean()); else if (val.isLong()) pd = new PathDetail(val.asLong()); else if (val.isInt()) pd = new PathDetail(val.asInt()); else if (val.isDouble()) pd = new PathDetail(val.asDouble()); else if (val.isTextual()) pd = new PathDetail(val.asText()); else throw new JsonParseException(jp, "Unsupported type of PathDetail value " + pathDetail.getNodeType().name()); pd.setFirst(from.asInt()); pd.setLast(to.asInt()); return pd; } }
return jsonNode.asLong(); } else if (jsonNode.isLong()) { return jsonNode.asLong(); } else if (jsonNode.isDouble() || jsonNode.isFloat()) {
} else if (e.isInt()) { return e.asInt(); } else if (e.isLong()) { return e.asLong(); } else if (e.isBigDecimal()) {
private Object valueFromJsonNode(String path, JsonNode valueNode) { if (valueNode == null || valueNode.isNull()) { return null; } else if (valueNode.isTextual()) { return valueNode.asText(); } else if (valueNode.isFloatingPointNumber()) { return valueNode.asDouble(); } else if (valueNode.isBoolean()) { return valueNode.asBoolean(); } else if (valueNode.isInt()) { return valueNode.asInt(); } else if (valueNode.isLong()) { return valueNode.asLong(); } else if (valueNode.isObject() || (valueNode.isArray())) { return new JsonLateObjectEvaluator(mapper, valueNode); } throw new PatchException( String.format("Unrecognized valueNode type at path %s and value node %s.", path, valueNode)); } }
private Object parseId(JsonNode node) { if (isNullNodeOrValue(node)) { return null; } if (node.isDouble()) { return node.asDouble(); } if (node.isFloatingPointNumber()) { return node.asDouble(); } if (node.isInt()) { return node.asInt(); } if (node.isLong()) { return node.asLong(); } //TODO(donequis): consider parsing bigints if (node.isIntegralNumber()) { return node.asInt(); } if (node.isTextual()) { return node.asText(); } throw new IllegalArgumentException("Unknown id type"); }
} else if (e.isInt()) { return e.asInt(); } else if (e.isLong()) { return e.asLong(); } else if (e.isBigDecimal()) {
@Test public void idLongType() throws Exception { EasyMock.expect(mockService.testMethod(param1)).andReturn(param1); EasyMock.replay(mockService); jsonRpcServer.handleRequest(messageWithListParamsStream(longParam, "testMethod", param1), byteArrayOutputStream); assertTrue(decodeAnswer(byteArrayOutputStream).get(ID).isLong()); }
@JsonIgnore @Deprecated public boolean isLongFrom() { return from.isLong(); }
@JsonIgnore @Deprecated public boolean isLongTo() { return to.isLong(); }
private Long getLongField(final JsonNode pNode, final String pFieldName) { Preconditions.checkNotNull(pNode); Preconditions.checkNotNull(pFieldName); return (pNode.get(pFieldName) != null && pNode.get(pFieldName).isLong()) ? pNode.get(pFieldName).longValue() : null; }
private Long getLongField(final JsonNode pNode, final String pFieldName) { Preconditions.checkNotNull(pNode); Preconditions.checkNotNull(pFieldName); return (pNode.get(pFieldName) != null && pNode.get(pFieldName).isLong()) ? pNode.get(pFieldName).longValue() : null; }
/** * @return false if db is an Cloudant instance. */ public boolean isUpdateSeqNumeric() { return updateSeq != null && (updateSeq.isInt() || updateSeq.isLong()); }
@Override public Object parseJsonNode(JsonNode input, Schema schema) { Preconditions.checkState(input.isLong(), "'%s' is not a '%s'", input.textValue(), expectedClass().getSimpleName()); return input.longValue(); } }
private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) { return node.isShort() ? EdmPrimitiveTypeKind.Int16 : node.isInt() ? EdmPrimitiveTypeKind.Int32 : node.isLong() ? EdmPrimitiveTypeKind.Int64 : node.isBoolean() ? EdmPrimitiveTypeKind.Boolean : node.isFloat() ? EdmPrimitiveTypeKind.Single : node.isDouble() ? EdmPrimitiveTypeKind.Double : node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal : EdmPrimitiveTypeKind.String; }