本文整理汇总了Java中com.mongodb.DBObject.toMap方法的典型用法代码示例。如果您正苦于以下问题:Java DBObject.toMap方法的具体用法?Java DBObject.toMap怎么用?Java DBObject.toMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.DBObject
的用法示例。
在下文中一共展示了DBObject.toMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sessionWrapperWithNoMaxIntervalShouldFallbackToDefaultValues
import com.mongodb.DBObject; //导入方法依赖的package包/类
@Test
public void sessionWrapperWithNoMaxIntervalShouldFallbackToDefaultValues() {
// given
MongoSession toSerialize = new MongoSession();
DBObject dbObject = convertToDBObject(toSerialize);
Document document = new Document(dbObject.toMap());
document.remove("interval");
// when
MongoSession convertedSession = this.mongoSessionConverter.convert(document);
// then
assertThat(convertedSession.getMaxInactiveInterval()).isEqualTo(Duration.ofMinutes(30));
}
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:16,代码来源:JdkMongoSessionConverterTest.java
示例2: deal2
import com.mongodb.DBObject; //导入方法依赖的package包/类
private void deal2(Operator operator, Object object, DBObject baseObject)
{
if (!(object instanceof MongoCondition))
{
throw new ConditionException("value should be type of " + getClass()
+ ".current type is "
+ object.getClass());
}
MongoCondition condition = (MongoCondition) object;
if (operator == NOT)
{
baseObject.put("$not", condition.toFinalObject());
} else if (operator == OR)
{
baseObject.put("$or", condition.toDBList());
} else if (operator == AND)
{
DBObject andCondition = (DBObject) condition.toFinalObject();
Map<String, Object> andMap = andCondition == null ? null : andCondition.toMap();
if (andMap != null && andMap.size() > 0)
{
BasicDBList dbList = new BasicDBList();
baseObject.put("$and", dbList);
for (Map.Entry<String, Object> entry : andMap.entrySet())
{
dbList.add(new BasicDBObject(entry.getKey(), entry.getValue()));
}
}
} else if (operator instanceof MOperator._Operator)
{
baseObject.put(operator.toString(), condition.toFinalObject());
} else
{
throw new ConditionException("the operator should be _Operator, " + NOT
+ " or "
+ OR
+ " for value of Condition type");
}
}