Liron Ar has uploaded a new change for review.

Change subject: core: adding BusinessEntityHelper (with buildIdMap)
......................................................................

core: adding BusinessEntityHelper (with buildIdMap)

This patch adds BusinessEntityHelper class to provide helper methods for
BusinessEntity objects, an common use case is to build a map in which
the id is retrieved from the entity getId() method while the value is
the entity.

Change-Id: Id9349aea29e68368ddbe39f63d33f30144ab73cd
Signed-off-by: Liron Aravot <lara...@redhat.com>
---
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/BusinessEntityHelper.java
1 file changed, 21 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/26261/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/BusinessEntityHelper.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/BusinessEntityHelper.java
new file mode 100644
index 0000000..356b53f
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/BusinessEntityHelper.java
@@ -0,0 +1,21 @@
+package org.ovirt.engine.core.common.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ovirt.engine.core.common.businessentities.BusinessEntity;
+import org.ovirt.engine.core.compat.Guid;
+
+public class BusinessEntityHelper {
+
+    private BusinessEntityHelper() {}
+
+    public static <T extends BusinessEntity<Guid>> Map<Guid, T> 
buildIdMap(Iterable<T> businessEntities) {
+        Map<Guid, T> toReturn = new HashMap<Guid, T>();
+        for (T entity : businessEntities) {
+            toReturn.put(entity.getId(), entity);
+        }
+
+        return toReturn;
+    }
+}


-- 
To view, visit http://gerrit.ovirt.org/26261
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id9349aea29e68368ddbe39f63d33f30144ab73cd
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <lara...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to