com.mongodb.BasicDBObject.copy()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(110)

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

BasicDBObject.copy介绍

[英]Creates a new instance which is a copy of this BasicDBObject.
[中]创建一个新实例,该实例是此BasicDBObject的副本。

代码示例

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

/**
 * Creates a new instance which is a copy of this BasicDBObject.
 *
 * @return a BasicDBObject with exactly the same values as this instance.
 */
public Object copy() {
  // copy field values into new object
  BasicDBObject newCopy = new BasicDBObject(this.toMap());
  // need to clone the sub obj
  for (final String field : keySet()) {
    Object val = get(field);
    if (val instanceof BasicDBObject) {
      newCopy.put(field, ((BasicDBObject) val).copy());
    } else if (val instanceof BasicDBList) {
      newCopy.put(field, ((BasicDBList) val).copy());
    }
  }
  return newCopy;
}

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

/**
 * Copies this instance into a new Object.
 *
 * @return a new BasicDBList with the same values as this instance
 */
public Object copy() {
  // copy field values into new object
  BasicDBList newobj = new BasicDBList();
  // need to clone the sub obj
  for (int i = 0; i < size(); ++i) {
    Object val = get(i);
    if (val instanceof BasicDBObject) {
      val = ((BasicDBObject) val).copy();
    } else if (val instanceof BasicDBList) {
      val = ((BasicDBList) val).copy();
    }
    newobj.add(val);
  }
  return newobj;
}

代码示例来源:origin: eBay/YiDB

public BsonEntity(BsonEntity entity){
  super(entity.getMetaClass());
  bsonObject = new BasicDBObject((BasicDBObject)entity.getNode().copy());
}

代码示例来源:origin: com.foursquare/fongo

T clone = (T) ((BasicDBObject) source).copy();
return clone;

代码示例来源:origin: eBay/YiDB

public BsonEntity(BsonEntity entity){
  super(entity.getMetaClass());
  bsonObject = new BasicDBObject((BasicDBObject)entity.getNode().copy());
}

代码示例来源:origin: com.redhat.lightblue.mongo/lightblue-mongo

DBObject original = (DBObject) ((BasicDBObject) doc).copy();
try {
  DocTranslator.populateDocHiddenFields(doc, fields);

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

/**
 * Creates a new instance which is a copy of this BasicDBObject.
 *
 * @return a BasicDBObject with exactly the same values as this instance.
 */
public Object copy() {
  // copy field values into new object
  BasicDBObject newCopy = new BasicDBObject(this.toMap());
  // need to clone the sub obj
  for (final String field : keySet()) {
    Object val = get(field);
    if (val instanceof BasicDBObject) {
      newCopy.put(field, ((BasicDBObject) val).copy());
    } else if (val instanceof BasicDBList) {
      newCopy.put(field, ((BasicDBList) val).copy());
    }
  }
  return newCopy;
}

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

/**
 * Copies this instance into a new Object.
 *
 * @return a new BasicDBList with the same values as this instance
 */
public Object copy() {
  // copy field values into new object
  BasicDBList newobj = new BasicDBList();
  // need to clone the sub obj
  for (int i = 0; i < size(); ++i) {
    Object val = get(i);
    if (val instanceof BasicDBObject) {
      val = ((BasicDBObject) val).copy();
    } else if (val instanceof BasicDBList) {
      val = ((BasicDBList) val).copy();
    }
    newobj.add(val);
  }
  return newobj;
}

代码示例来源:origin: eBay/YiDB

BasicDBObject obj = (BasicDBObject)((BasicDBObject)currentEntity.getNode()).copy();
searchResult.addEntity(context.getEntityFactory().createEntity(currentEntity.getMetaClass(), obj));

相关文章