Moti Asayag has uploaded a new change for review.

Change subject: core: Cleanup and Refactor VmInterfaceType
......................................................................

core: Cleanup and Refactor VmInterfaceType

The patch includes the following:
* Use meaningful names for variable
* Set explicit speed for each driver
* Remove private c'tor from enum

Change-Id: Ib4a75f51f0ce04f94278bec55809185677634df5
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInterfaceType.java
1 file changed, 16 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/9299/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInterfaceType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInterfaceType.java
index 1b3f724..7bddf93 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInterfaceType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInterfaceType.java
@@ -1,16 +1,18 @@
 package org.ovirt.engine.core.common.businessentities;
 
 import java.util.HashMap;
+import java.util.Map;
 
 public enum VmInterfaceType {
-    rtl8139_pv(0,"Dual mode rtl8139, Red Hat VirtIO"),
-    rtl8139(1,"rtl8139"),
-    e1000(2,"e1000"),
-    pv(3,"Red Hat VirtIO");
+    rtl8139_pv(0, "Dual mode rtl8139, Red Hat VirtIO", 1000),
+    rtl8139(1, "rtl8139", 100),
+    e1000(2, "e1000", 1000),
+    pv(3, "Red Hat VirtIO", 1000);
 
-    private int intValue;
-    private String interfaceTranslation;
-    private static java.util.HashMap<Integer, VmInterfaceType> mappings = new 
HashMap<Integer, VmInterfaceType>();
+    private int id;
+    private String name;
+    private int speed;
+    private static Map<Integer, VmInterfaceType> mappings = new 
HashMap<Integer, VmInterfaceType>();
 
     static {
         for (VmInterfaceType vmInterfaceType : values()) {
@@ -18,22 +20,18 @@
         }
     }
 
-    private VmInterfaceType(int value) {
-        this(value, null);
+    private VmInterfaceType(int id, String name, int speed) {
+        this.id = id;
+        this.name = name;
+        this.speed = speed;
     }
-
-    private VmInterfaceType(int value, String interfaceTranslationVal) {
-        intValue = value;
-        interfaceTranslation = interfaceTranslationVal;
-    }
-
 
     public String getInterfaceTranslation() {
-        return interfaceTranslation;
+        return name;
     }
 
     public int getValue() {
-        return intValue;
+        return id;
     }
 
     public static VmInterfaceType forValue(int value) {
@@ -41,9 +39,6 @@
     }
 
     public int getSpeed() {
-        if (this == VmInterfaceType.rtl8139) {
-            return 100;
-        }
-        return 1000;
+        return speed;
     }
 }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4a75f51f0ce04f94278bec55809185677634df5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to