本文整理汇总了Java中com.typesafe.config.ConfigValueType.NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java ConfigValueType.NUMBER属性的具体用法?Java ConfigValueType.NUMBER怎么用?Java ConfigValueType.NUMBER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.typesafe.config.ConfigValueType
的用法示例。
在下文中一共展示了ConfigValueType.NUMBER属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: currentNumericNode
protected JsonNode currentNumericNode() throws JsonParseException {
ConfigValue configValue = currentNode();
if ((configValue == null) || (configValue.valueType() != ConfigValueType.NUMBER)) {
JsonToken t = (configValue == null) ? null : ConfigNodeCursor.forConfigValue(configValue);
throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
}
Number value = (Number) configValue.unwrapped();
if (value instanceof Double) {
return JsonNodeFactory.instance.numberNode((Double) value);
}
if (value instanceof Long) {
return JsonNodeFactory.instance.numberNode((Long) value);
}
if (value instanceof Integer) {
return JsonNodeFactory.instance.numberNode((Integer) value);
}
// only possible if Config has since added more numeric types
throw _constructError(value.getClass() + " is not a supported numeric config type");
}
示例2: getValueTypeOrNull
private static ConfigValueType getValueTypeOrNull(Class<?> parameterClass) {
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
return ConfigValueType.BOOLEAN;
} else if (parameterClass == Integer.class || parameterClass == int.class) {
return ConfigValueType.NUMBER;
} else if (parameterClass == Double.class || parameterClass == double.class) {
return ConfigValueType.NUMBER;
} else if (parameterClass == Long.class || parameterClass == long.class) {
return ConfigValueType.NUMBER;
} else if (parameterClass == String.class) {
return ConfigValueType.STRING;
} else if (parameterClass == Duration.class) {
return null;
} else if (parameterClass == ConfigMemorySize.class) {
return null;
} else if (parameterClass == List.class) {
return ConfigValueType.LIST;
} else if (parameterClass == Map.class) {
return ConfigValueType.OBJECT;
} else if (parameterClass == Config.class) {
return ConfigValueType.OBJECT;
} else if (parameterClass == ConfigObject.class) {
return ConfigValueType.OBJECT;
} else if (parameterClass == ConfigList.class) {
return ConfigValueType.LIST;
} else {
return null;
}
}
示例3: currentNumericNode
protected ConfigValue currentNumericNode()
throws JsonParseException
{
ConfigValue n = currentNode();
if (n == null || n.valueType() != ConfigValueType.NUMBER) {
JsonToken t = (n == null) ? null : asJsonToken(n);
throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
}
return n;
}