Closed ahjohannessen closed 1 year ago
Hi @ahjohannessen
Apologies for the delay.
The methods were deprecated for three reasons:
ByteBuffer
or BinaryCodec
class to transform the UUID into a byte array.I thought no one was using these methods because they were so unusual. I couldn't find any use of these methods here on Github.
However, now that I know someone is using them, I no longer intend to deprecate them. On the contrary, I'm happy that this library is being useful. Thanks for keeping me from breaking the golden rule of public interfaces!
Soon, I will release a patch version that undoes deprecation.
P.S. The GUID.v8()
method will continue deprecated and will be removed when the new RFC is finally published.
Thanks for your answer :) We changed our code to use uuid.toString, but good to know the reasoning behind the deprecation.
Hi @ahjohannessen !
I just want to let you know that I changed my mind again.
The methods with UUID as the name parameter will continue deprecated.
Before the removal, UUIDs can be used as the name parameter like this:
UUID hashed = UuidCreator.getNameBasedMd5(uuid);
In the future, after the removal, you'll have to add a statement using ByteBuffer
to convert the UUID into a byte array:
byte[] name = ByteBuffer.allocate(16)
.putLong(uuid.getMostSignificantBits())
.putLong(uuid.getLeastSignificantBits())
.array();
UUID hashed = UuidCreator.getNameBasedMd5(name);
Alternatively, you can add a single line using BinaryCodec
which is as efficient as the current method implementation, doing the same as ByteBuffer
:
byte[] name = BinaryCodec.INSTANCE.encode(uuid);
UUID hashed = UuidCreator.getNameBasedMd5(name);
I know that it wont affect your project anymore as you changed to uuid.toString()
. But I want to express the change in my opinion due to other developers who might think that the deprecation will be undone.
The objective is to fix a ~dumb~ mistake of mine while designing and implementing the hash-based generators. Today they only exist to confuse the users of the library by adding lots of methods which are basically the same.
Best regards.
Hi @fabiolimace
I wondered why the name-based methods with a UUID name parameter are being deprecated?
We use it to derive deterministic UUIDs.