/** * 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; }
/** * 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; }
T clone = (T) ((BasicDBList) source).copy(); return clone;
/** * 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; }
/** * 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; }