Allon Mureinik has uploaded a new change for review. Change subject: core: Organize Guid's methods ......................................................................
core: Organize Guid's methods Organize the Guid class in a sensible way - group all the constructors together, all the constants together, all the static creators together, etc. Change-Id: Ic4f96869fecebed9e843e6a85bf1de8db3d056cf Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/Guid.java 1 file changed, 31 insertions(+), 33 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/15692/1 diff --git a/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/Guid.java b/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/Guid.java index a625708..c030e70 100644 --- a/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/Guid.java +++ b/backend/manager/modules/compat/src/main/java/org/ovirt/engine/core/compat/Guid.java @@ -4,35 +4,30 @@ import java.util.UUID; public class Guid implements Serializable, Comparable<Guid> { + /** + * Needed for the serialization/deserialization mechanism. + */ + private static final long serialVersionUID = 27305745737022810L; protected static final String EMPTY_GUID_VALUE = "00000000-0000-0000-0000-000000000000"; public static final Guid SYSTEM = new Guid("AAA00000-0000-0000-0000-123456789AAA"); public static final Guid EVERYONE = new Guid("EEE00000-0000-0000-0000-123456789EEE"); public final static Guid Empty = new Guid(); - /** - * Needed for the serialization/deserialization mechanism. - */ - private static final long serialVersionUID = 27305745737022810L; - private static final byte[] CHANGE_BYTE_ORDER_INDICES = { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 }; private static final byte[] KEEP_BYTE_ORDER_INDICES = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - - public static Guid NewGuid() { - return new Guid(UUID.randomUUID()); - } - - public static boolean isNullOrEmpty(Guid id) { - return id == null || id.equals(Empty); - } protected UUID uuid; public Guid() { this(EMPTY_GUID_VALUE); + } + + public Guid(UUID uuid) { + this.uuid = uuid; } public Guid(byte[] guid, boolean keepByteOrder) { @@ -56,6 +51,14 @@ } } + public Guid getValue() { + return this; + } + + public static Guid NewGuid() { + return new Guid(UUID.randomUUID()); + } + public static Guid createGuidFromString(String candidate) { if (candidate == null) { return null; @@ -72,20 +75,8 @@ } } - public Guid(UUID uuid) { - this.uuid = uuid; - } - - public Guid getValue() { - return this; - } - - @Override - public String toString() { - if (uuid == null) - return "[null]"; - else - return uuid.toString(); + public static boolean isNullOrEmpty(Guid id) { + return id == null || id.equals(Empty); } public UUID getUuid() { @@ -104,6 +95,19 @@ @Override public int hashCode() { return uuid.hashCode(); + } + + @Override + public int compareTo(Guid other) { + return this.getUuid().compareTo(other.getUuid()); + } + + @Override + public String toString() { + if (uuid == null) + return "[null]"; + else + return uuid.toString(); } /** @@ -163,10 +167,4 @@ return (k <= 0xF) ? "0" + Integer.toHexString(k) : Integer .toHexString(k); } - - @Override - public int compareTo(Guid other) { - return this.getUuid().compareTo(other.getUuid()); - } - } -- To view, visit http://gerrit.ovirt.org/15692 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic4f96869fecebed9e843e6a85bf1de8db3d056cf 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