core: Remove Guid.OpEquals(Guid, Guid)

OpEquals was only used in two places in the codebase, and both have at
least one value known to be non-null.
Hence, this method could be removed, and replaced by a simple call to
Guid.equals(Object).

Change-Id: I3c0f79f2161f4beca5b048ca74acaf63c11753e3
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: Don't use createGuidFromString on literals

Guid.createGuidFromString(String) and NGuid.createGuidFromString(String)
are utility methods that wrap new Guid(String) and return a default
(null or Guid.Empty) in case the string passed to them is null.

This means that there is no point in using them when working with
hard-coded string literals, and a simple call to new Guid("...") would
suffice.

Change-Id: I79780b701c6d156e0cdef983fb1a29d6c21b7b4e
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: Unify Guid and NGuid

Guid and NGuid are essentially the same class, where the only
difference is the value returned from createGuidFromString(String) in
case the parameter is null (null vs. Guid.Empty) and a couple of
constants.

Since this method is static anyway, and most places use Guid anyway,
NGuid can be removed as a separate class.
Moreover, NGuid's hierarchy is obviously broken, as it holds a cache for
a Guid instance, which in turn, extends NGuid.

This patch does the following:
1. Renames Guid.createGuidFromString(String) to
   createGuidFromStringDefaultEmpty, in order to overload it with
   NGuid.createGuidFromString(String).
2. Squashed NGuid and Guid together and retained the name Guid. All
   occurrences of NGuid in the code were replaced with Guid.
3. Renamed NGuidTest to GuidTest, since NGuid no longer exists.
4. Renamed JsonNGuidMixIn to JsonGuidMixIn, since NGuid no longer
   exists.
5. Removed specific references in JsonObjectSerializer,
   JsonObjectDeserializer and their tests.
6. Removed NGuid's entry from Compat.gwt.xml.

This patch leaves some work to be done, which was not including simply
because of the size/scope of this patch.
Consecutive patches will handle these cleanups.

Change-Id: I4af6d353ef27394ff902f374de19682628c52739
Signed-off-by: Allon Mureinik <amureini@redhat.com>
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 <amureini@redhat.com>
engine: Remove Guid.getValue()

After the unification of the NGuid and Guid, the getValue() method in
Guid (inherited from NGuid) becomes useless - it simply returns a
reference to the same Guid object (i.e., this) and thus can safely be
removed.

This patch removes the aforementioned method and all its usages.

Change-Id: Ie902cfd945dab9358e480ded27cf96e91e38139b
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Remove GuidUtils.getGuidValue(Guid)

Since the unification of Guid and NGuid, this method is meaningless.

Change-Id: I9b2e64199f634f25f1d2c0c224e1a13b380ba36f
Signed-off-by: Allon Mureinik <amureini@redhat.com>
restapi: Remove BaseBackendResource.asGuid(Guid)

This the unification of Guid and NGuid, this method is meaningless, and
thus should be removed.

Change-Id: Ifbc773fcc57ae182dc6b16091eb2662f688b706f
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Unwrap else blocks in Guid

Unwrapped a couple of else blocks where the if does not terminate
normally.

Change-Id: I05ae00a16ac86d93d011af0addea112a6baa63cc
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: Renamed Guid.NewGuid() to Guid.newGuid()

Renamed the method to conform to Java conventions.

Change-Id: Icfedd300b081ecd7dc0cb4faedadd36d047b66cf
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: Deprecate new Guid()

Guid's default constructor created a new Guid object equal to
Guid.Empty, which is quite redundant since Guids are immutable.
Moreover, the default constructor just delegated to the String
constructor, forcing an expensive UUID.fromString(EMPTY_GUID_VALUE)
to be called on each invocation of new Guid().

In order to solve the performance issues here, the following was done:
1. The default constructor was changed to call the cheap UUID
   constructor instead of the expensive String constructor.
2. The default constructor was changed to private and marked as
   @Deprecated so it won't be called externally. Unfortunately, it could
   not be removed completely due to GWT limitations.
3. All the usages of new Guid() we removed and replaced by Guid.Empty
   for production code or by Guid.newGuid() for testing code (in order
   to provide some randomness, and hence, better robustness for the
   test).

Change-Id: Id80dc50896a9874731300f543a72838c345cbcdd
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Fix Guid's members modifiers

Changed all of Guid's protected methods to be private for better
encapsulation.

Change-Id: I5a5397962976c9058e7ddda0a530136ff16b14b2
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Remove Guid.EMPTY_GUID_VALUE

Remove the EMPTY_GUID_VALUE constant from the Guid class.
In all the places it's used as a default Guid.Empty can be used instead,
which would result in a better memory footprint.

Change-Id: I771a1e1030e797d7844125680e7399fbc82d91ae
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Rename Guid.AddLeadingZero

AddLeadingZero was renamed to addLeadingZero in order to conform to Java
naming conventions.

Change-Id: I1a1771981548b7a7263d2e05cb168d3d9352b6d9
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Cleanup Guid(byte[], boolean)

Since getStrRepresentationOfGuid(byte[], boolean) cannot return an empty
string, this check can be removed from the said constructor.

Change-Id: I0e992946f4c73c7e7f5d89a691a0b841d38c888b
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Cleanup Guid.toString()

Since Guid.uuid can never be null the check in toString() is redundant,
and should hence be removed.

Change-Id: I0968f69faf4fef229dca50edc5944f7aa8384369
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Consolidate Guid.createFromStringXXX impl

Consolidated the implementation of Guid.createFromString(Stirng) and
Guid.createFromStringDefaultEmpty(String), and added some unit tests to
assure no functionality was broken.

Change-Id: I91521dd873c6c9a3594ea601d79954e8915d1a00
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Fix modifiers of getStrRepresentationOfGuid

This method is not used outside of the Guid class, and hence should be
private.

It also does not access any member variables, so it should be static.

Change-Id: I7ca9ed63077fc5a7c39c38900780afd14126fffc
Signed-off-by: Allon Mureinik <amureini@redhat.com>