热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.bson.BsonValue.asDecimal128()方法的使用及代码示例

本文整理了Java中org.bson.BsonValue.asDecimal128()方法的一些代码示例,展示了BsonValue.asDecimal128

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

BsonValue.asDecimal128介绍

[英]Gets this value as a BsonDecimal128 if it is one, otherwise throws exception
[中]如果此值为BsonDecimal128,则将其作为BsonDecimal128获取,否则将引发异常

代码示例

代码示例来源:origin: org.mongodb/mongo-java-driver

@Override
public Decimal128 doReadDecimal128() {
return currentValue.asDecimal128().getValue();
}

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
* Gets the value of the key if it is a BsonDecimal128, or throws if not.
*
* @param key the key
* @return the value of the key as a BsonDecimal128
* @throws org.bson.BsonInvalidOperationException if the document does not contain the key or the value is not of the expected type
* @since 3.4
*/
public BsonDecimal128 getDecimal128(final Object key) {
throwIfKeyAbsent(key);
return get(key).asDecimal128();
}

代码示例来源:origin: org.mongodb/mongo-java-driver

/**
* If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a
* BsonDecimal128.
*
* @param key the key
* @param defaultValue the default value
* @return the value of the key as a BsonDecimal128
* @throws org.bson.BsonInvalidOperationException if the document contains the key but the value is not of the expected type
* @since 3.4
*/
public BsonDecimal128 getDecimal128(final Object key, final BsonDecimal128 defaultValue) {
if (!containsKey(key)) {
return defaultValue;
}
return get(key).asDecimal128();
}

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

@Test
public void write() throws Exception {
JsonObject obj = new JsonObject();
BigInteger bigInteger = new BigInteger(Long.toString(Long.MAX_VALUE)).multiply(new BigInteger("128"));
obj.addProperty("bigInteger", bigInteger);
BigDecimal bigDecimal = new BigDecimal(Long.MAX_VALUE).multiply(new BigDecimal(1024));
obj.addProperty("bigDecimal", bigDecimal);
BsonDocument doc = Jsons.toBson(obj);
check(doc.get("bigInteger").getBsonType()).is(BsonType.DECIMAL128);
check(doc.get("bigInteger").asDecimal128().decimal128Value().bigDecimalValue().toBigInteger()).is(bigInteger);
check(doc.get("bigDecimal").getBsonType()).is(BsonType.DECIMAL128);
check(doc.get("bigDecimal").asDecimal128().decimal128Value().bigDecimalValue()).is(bigDecimal);
}

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

@Test
public void bigNumbers() throws Exception {
JsonObject obj = new JsonObject();
BigInteger bigInteger = new BigInteger(Long.toString(Long.MAX_VALUE)).multiply(new BigInteger("128"));
obj.addProperty("bigInteger", bigInteger);
BigDecimal bigDecimal = new BigDecimal(Long.MAX_VALUE).multiply(new BigDecimal(1024));
obj.addProperty("bigDecimal", bigDecimal);
BsonDocument bson = Jsons.toBson(obj);
check(bson.get("bigInteger").getBsonType()).is(BsonType.DECIMAL128);
check(bson.get("bigInteger").asDecimal128().decimal128Value().bigDecimalValue().toBigInteger()).is(bigInteger);
check(bson.get("bigDecimal").getBsonType()).is(BsonType.DECIMAL128);
check(bson.get("bigDecimal").asDecimal128().decimal128Value().bigDecimalValue()).is(bigDecimal);
check(Jsons.toGson(bson)).is(obj);
}
}

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

colValue = keyvalueforStruct.getValue().asDecimal128().getValue().toString();
break;
list.add(temp);
} else if (arrValue.getBsonType() == BsonType.DECIMAL128 && valueType == BsonType.DECIMAL128) {
String temp = arrValue.asDecimal128().getValue().toString();
list.add(temp);
} else if (arrValue.getBsonType() == BsonType.TIMESTAMP && valueType == BsonType.TIMESTAMP) {

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

return value.asString().getValue();
case DECIMAL128:
return value.asDecimal128().doubleValue();
case DOUBLE:
return value.asDouble().getValue();

代码示例来源:origin: org.mongodb/mongo-java-driver

break;
case DECIMAL128:
writeDecimal128(value.asDecimal128().getValue());
break;
case MIN_KEY:

代码示例来源:origin: org.springframework.data/spring-data-mongodb

return value.asString().getValue();
case DECIMAL128:
return value.asDecimal128().doubleValue();
case DOUBLE:
return value.asDouble().getValue();

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

public static Object extractValueEx(BsonValue value) {
switch (value.getBsonType()) {
case DOUBLE:
return value.asDouble().getValue();
case STRING:
return value.asString().getValue();
case OBJECT_ID:
return value.asObjectId().getValue();
case INT32:
return value.asInt32().getValue();
case INT64:
return value.asInt64().getValue();
case DECIMAL128:
return value.asDecimal128().getValue();
case NULL:
return null;
}
throw new IllegalArgumentException("Unsupported ID type: " + value.getClass());
}

代码示例来源:origin: com.torodb.mongowp.bson/org-bson-utils

value.asDecimal128().decimal128Value().getHigh(),
value.asDecimal128().decimal128Value().getLow());
case Javascript_WITH_SCOPE: {
BsonJavascriptWithScope casted = value.asJavascriptWithScope();

推荐阅读
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • JavaSE笔试题-接口、抽象类、多态等问题解答
    本文解答了JavaSE笔试题中关于接口、抽象类、多态等问题。包括Math类的取整数方法、接口是否可继承、抽象类是否可实现接口、抽象类是否可继承具体类、抽象类中是否可以有静态main方法等问题。同时介绍了面向对象的特征,以及Java中实现多态的机制。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
author-avatar
张俊凯宜珮
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有