From: Sweidan Omar Date: Thu, 28 Apr 2022 06:37:04 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=d4cacdfe8ba8971c7150eebefdcb22514f5b2276;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C33215 --- diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java b/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java index 95f05ce8..f2d298f4 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java @@ -3,6 +3,7 @@ package user.commons.nosql; import java.sql.Connection; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import javax.sql.DataSource; @@ -81,7 +82,7 @@ public class NoSQLUtils { result = new ArrayList<>(); result.add((BasicDBObject) listobj); } - //result = Arrays.asList(dbList.toArray(new BasicDBObject[obj.size()])); + // result = Arrays.asList(dbList.toArray(new BasicDBObject[obj.size()])); } } @@ -148,4 +149,23 @@ public class NoSQLUtils { return result; } + + /** + * Returns a deep copy of source + * + * @param source a BasicDBObject to be deep-copied + * @return the deep-copy of source + */ + public static BasicDBObject deepCopy(BasicDBObject source) { + BasicDBObject target = new BasicDBObject(); + HashMap sourceAsMap = (HashMap) source.toMap(); + + for (HashMap.Entry entry : sourceAsMap.entrySet()) { + String key = entry.getKey(); + Object val = entry.getValue(); + target.put(key, val); + } + + return target; + } }