Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String-to-UUID Converter. #4400

Closed
basil-bourque opened this issue Jul 15, 2018 · 1 comment
Closed

String-to-UUID Converter. #4400

basil-bourque opened this issue Jul 15, 2018 · 1 comment

Comments

@basil-bourque
Copy link

basil-bourque commented Jul 15, 2018

[This Issue parallels one posted for Vaadin 8 Framework, Issue # 11,051.]

Vaadin 8 Framework offers several handy implementations of Converter such as StringToBooleanConverter and StringToIntegerConverter.

I suggest adding another for the common type java.util.UUID for Universally unique identifier (UUID) values. UUID values are common in enterprise apps for generating identifiers without needing a central registration authority.

The 128 bits of a UUID are canonically presented as five groups of hexadecimal digits separated by a hyphen, such as ab664df2-8859-11e8-9a94-a6cf71072f73, as discussed in Wikipedia, the java.util.UUID::toString JavaDoc, and the RFC 4122 spec.

The implementation is utterly simple, with only two core lines of code:

String s = myUuid.toString() ;

and

UUID myUuid = UUID.fromString( s ) ;

Attached is a single StringToUuidConverter.java.txt file, my take on an implementation. (GitHub would not accept .java, so I appended .txt to the file name.)

StringToUuidConverter.java.txt

@stbischof
Copy link
Contributor

Hi, a bit more complex but more powerful.
Using OSGI-Converter for all convertation.

https://blog.osgi.org/2018/04/osgi-r7-highlights-converter.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants