f4b6a3 / uuid-creator

UUID Creator is a Java library for generating Universally Unique Identifiers.
MIT License
430 stars 44 forks source link

UriCodec.isUuidUrn(java.net.URI uri) #66

Closed buko closed 2 years ago

buko commented 2 years ago

Minor issue:

UriCodec should provide a static method to determine if a URI is a UUID:

public static boolean isUuidUrn(java.net.URI uri) { ... }

You can sort of do this by attempting to decode the URI and catching InvalidUuidException but there should be a better, more efficient way to implement this functionality.

(BTW, I now realize this class should be named UrnCodec not UriCodec. It's too late to change now without breaking a bunch of people but it turns out that everybody and their grandmother has a scheme for turning UUIDs into URIs instead of using the standard URN mechanism.)

fabiolimace commented 2 years ago

The static method you propose can be very useful. However, I have no plans to work on this repository this month.

I agree that UriCodec should be called UrnCodec and it's too late to change it. I chose the current name because of its java.net.URI parameter. I'm not good at picking names as you can see. That's why the package name is called f4b6a3. :)

I appreciate any help, as long as it passes the unit tests. PRs are welcome.

fabiolimace commented 2 years ago

Implemented UrnCodec to decode String instead of java.net.URI.

Also added a isUuidUri(java.net.URI) method to UriCodec.

I think there is no problem with the existence of UriCodec and UrnCodec. Both decode different types of objects.

fabiolimace commented 2 years ago

Released v5.0.0.