本文整理匯總了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;
}