com.fasterxml.jackson.databind.JsonNode.isLong()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isLong()方法的一些代码示例,展示了JsonNode.isLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isLong()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isLong

JsonNode.isLong介绍

[英]Method that can be used to check whether contained value is a number represented as Java long. Note, however, that even if this method returns false, it is possible that conversion would be possible from other numeric types -- to check if this is possible, use #canConvertToInt() instead.
[中]方法,该方法可用于检查所包含的值是否为表示为Javalong的数字。但是,请注意,即使此方法返回false,也有可能从其他数值类型进行转换——要检查这是否可行,请使用#canConvertToInt()代替。

代码示例

代码示例来源:origin: Graylog2/graylog2-server

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();
}

代码示例来源:origin: Graylog2/graylog2-server

@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();
  }
}

代码示例来源:origin: apache/incubator-druid

if (val.isInt() || val.isLong()) {
 return val.asLong();

代码示例来源:origin: joelittlejohn/jsonschema2pojo

/**
 * 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);
  }
}

代码示例来源:origin: Activiti/Activiti

if (resultNode.isBoolean()) {
  result = resultNode.asBoolean();
} else if (resultNode.isLong()) {
  result = resultNode.asLong();
} else if (resultNode.isBigDecimal() || resultNode.isDouble()) {

代码示例来源:origin: Graylog2/graylog2-server

} else if (valueType == ValueType.INTEGER && value.isInt()) {
  return ValueReference.of(value.intValue());
} else if (valueType == ValueType.LONG && (value.isLong() || value.isInt())) {

代码示例来源:origin: graphhopper/graphhopper

@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;
  }
}

代码示例来源:origin: apache/avro

return jsonNode.asLong();
} else if (jsonNode.isLong()) {
 return jsonNode.asLong();
} else if (jsonNode.isDouble() || jsonNode.isFloat()) {

代码示例来源:origin: json-path/JsonPath

} else if (e.isInt()) {
  return e.asInt();
} else if (e.isLong()) {
  return e.asLong();
} else if (e.isBigDecimal()) {

代码示例来源:origin: spring-projects/spring-data-rest

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));
  }
}

代码示例来源:origin: briandilley/jsonrpc4j

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");
}

代码示例来源:origin: com.jayway.jsonpath/json-path

} else if (e.isInt()) {
  return e.asInt();
} else if (e.isLong()) {
  return e.asLong();
} else if (e.isBigDecimal()) {

代码示例来源:origin: briandilley/jsonrpc4j

@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());
}

代码示例来源:origin: baidubce/bce-sdk-java

@JsonIgnore
@Deprecated
public boolean isLongFrom() {
  return from.isLong();
}

代码示例来源:origin: baidubce/bce-sdk-java

@JsonIgnore
@Deprecated
public boolean isLongTo() {
  return to.isLong();
}

代码示例来源:origin: apache/oozie

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;
}

代码示例来源:origin: org.apache.oozie/oozie-core

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;
}

代码示例来源:origin: helun/Ektorp

/**
 * @return false if db is an Cloudant instance.
 */
public boolean isUpdateSeqNumeric() {
  return updateSeq != null && (updateSeq.isInt() || updateSeq.isLong());
}

代码示例来源:origin: io.confluent.kafka/connect-utils

@Override
 public Object parseJsonNode(JsonNode input, Schema schema) {
  Preconditions.checkState(input.isLong(), "'%s' is not a '%s'", input.textValue(), expectedClass().getSimpleName());
  return input.longValue();
 }
}

代码示例来源:origin: org.apache.olingo/odata-client-core

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;
}

相关文章