本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.isIntegralNumber方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.isIntegralNumber方法的具体用法?Java JsonNode.isIntegralNumber怎么用?Java JsonNode.isIntegralNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.isIntegralNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: numEquals
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static boolean numEquals(final JsonNode a, final JsonNode b) {
/*
* If both numbers are integers, delegate to JsonNode.
*/
if (a.isIntegralNumber() && b.isIntegralNumber()) {
return a.equals(b);
}
/*
* Otherwise, compare decimal values.
*/
return a.decimalValue().compareTo(b.decimalValue()) == 0;
}
示例2: capacity
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
* Available Bandwidth resource (Capacity).
*
* @return {@link Bandwidth}
*/
public Bandwidth capacity() {
JsonNode v = object.path(CAPACITY);
if (v.isIntegralNumber()) {
return Bandwidth.mbps(v.asLong());
} else if (v.isFloatingPointNumber()) {
return Bandwidth.mbps(v.asDouble());
} else {
log.warn("Unexpected JsonNode for {}: {}", CAPACITY, v);
return Bandwidth.mbps(v.asDouble());
}
}
示例3: convertToConnect
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static Object convertToConnect(Schema schema, JsonNode jsonValue) {
final Schema.Type schemaType;
if (schema != null) {
schemaType = schema.type();
if (jsonValue.isNull()) {
if (schema.defaultValue() != null)
return schema.defaultValue(); // any logical type conversions should already have been applied
if (schema.isOptional())
return null;
throw new DataException("Invalid null value for required " + schemaType + " field");
}
} else {
switch (jsonValue.getNodeType()) {
case NULL:
// Special case. With no schema
return null;
case BOOLEAN:
schemaType = Schema.Type.BOOLEAN;
break;
case NUMBER:
if (jsonValue.isIntegralNumber())
schemaType = Schema.Type.INT64;
else
schemaType = Schema.Type.FLOAT64;
break;
case ARRAY:
schemaType = Schema.Type.ARRAY;
break;
case OBJECT:
schemaType = Schema.Type.MAP;
break;
case STRING:
schemaType = Schema.Type.STRING;
break;
case BINARY:
case MISSING:
case POJO:
default:
schemaType = null;
break;
}
}
final JsonToConnectTypeConverter typeConverter = TO_CONNECT_CONVERTERS.get(schemaType);
if (typeConverter == null)
throw new DataException("Unknown schema type: " + String.valueOf(schemaType));
Object converted = typeConverter.convert(schema, jsonValue);
if (schema != null && schema.name() != null) {
LogicalTypeConverter logicalConverter = TO_CONNECT_LOGICAL_CONVERTERS.get(schema.name());
if (logicalConverter != null)
converted = logicalConverter.convert(schema, converted);
}
return converted;
}