I'm preparing a Java library that need to assign a unique id to the generated objects for serialization purposes. Once a unique id is generated, I have to ensure that the next time I use the library, there is no possibility to reassign an id to an object that I already saved in the past.
Now, I see that many in Stackoverflow suggest to rely on a couple of options, i.e. UUID
, SecureRandom
, but I'm not sure that this classes suits my needs and I'm not sure about how to use them.
Please, can you address myself to the right utility to use and how to generate the id?
Solutions based on utility from Guava/Apache are welcome.