Nir Soffer has uploaded a new change for review.

Change subject: engine: Cleaner and more robust StorageType
......................................................................

engine: Cleaner and more robust StorageType

Using subtype, StorageType implemenation can be simpler, more clear, and
less error prone. Adding new type should be one line change now.

Change-Id: Ie05d5e85f152040d3ffbcc57333bce57fc74c616
Signed-off-by: Nir Soffer <nsof...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
1 file changed, 16 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/28/22328/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
index b8358df..9ac2d33 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageType.java
@@ -4,16 +4,19 @@
 
 public enum StorageType implements Identifiable {
 
-    UNKNOWN(0),
-    NFS(1),
-    FCP(2),
-    ISCSI(3),
-    LOCALFS(4),
-    POSIXFS(6),
-    GLUSTERFS(7),
-    GLANCE(8);
+    UNKNOWN(0, Subtype.NONE),
+    NFS(1, Subtype.FILE),
+    FCP(2, Subtype.BLOCK),
+    ISCSI(3, Subtype.BLOCK),
+    LOCALFS(4, Subtype.FILE),
+    POSIXFS(6, Subtype.FILE),
+    GLUSTERFS(7, Subtype.FILE),
+    GLANCE(8, Subtype.FILE);
+
+    private enum Subtype { NONE, FILE, BLOCK }
 
     private int value;
+    private Subtype subtype;
 
     private static final HashMap<Integer, StorageType> mappings = new 
HashMap<Integer, StorageType>();
 
@@ -23,8 +26,9 @@
         }
     }
 
-    private StorageType(int value) {
+    private StorageType(int value, Subtype subtype) {
         this.value = value;
+        this.subtype = subtype;
     }
 
     @Override
@@ -33,7 +37,7 @@
     }
 
     public boolean isConcreteStorageType() {
-        return this != UNKNOWN;
+        return subtype != Subtype.NONE;
     }
 
     public static StorageType forValue(int value) {
@@ -41,10 +45,10 @@
     }
 
     public boolean isFileDomain() {
-        return this == NFS || this == POSIXFS || this == LOCALFS || this == 
GLUSTERFS || this == GLANCE;
+        return subtype == Subtype.FILE;
     }
 
     public boolean isBlockDomain() {
-        return this == FCP || this == ISCSI;
+        return subtype == Subtype.BLOCK;
     }
 }


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

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

Reply via email to