Allon Mureinik has uploaded a new change for review. Change subject: core: Add IDs to ImageStatus ......................................................................
core: Add IDs to ImageStatus Added IDs to the ImageStauts enum, as per the FIXME comment at the head of the class, in order to decouple the enum values from their ordinals. This is done in preparation to remove the unused INVALID status, so that ILLEGAL will retain its value when INVALID is removed. Change-Id: I364f95ea384e1742842066043780183e3d4244b6 Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStatus.java 1 file changed, 23 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/93/14193/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStatus.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStatus.java index 76e0850..bc5c454 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStatus.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStatus.java @@ -1,20 +1,34 @@ package org.ovirt.engine.core.common.businessentities; +import java.util.HashMap; +import java.util.Map; + public enum ImageStatus implements Identifiable { - // FIXME add ids and remove the ordinal impl of getValue - Unassigned, - OK, - LOCKED, - INVALID, - ILLEGAL; + Unassigned(0), + OK(1), + LOCKED(2), + INVALID(3), + ILLEGAL(4); + + private int intValue; + private static Map<Integer, ImageStatus> mappings = new HashMap<Integer, ImageStatus>(); + + static { + for (ImageStatus imageStatus : values()) { + mappings.put(imageStatus.getValue(), imageStatus); + } + } + + private ImageStatus(int value) { + intValue = value; + } @Override public int getValue() { - return this.ordinal(); + return intValue; } public static ImageStatus forValue(int value) { - return values()[value]; + return mappings.get(value); } - } -- To view, visit http://gerrit.ovirt.org/14193 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I364f95ea384e1742842066043780183e3d4244b6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches