It's all about the answers!

Ask a question

How can I distinguish between a name and UUID?


Geoff Alexander (18623839) | asked Sep 29 '20, 3:04 p.m.
edited Sep 29 '20, 3:17 p.m.

I'm working on a script that uses the RTC CLI to access RTC in which a user can reference an RTC object by either its name or its UUID.  How can I determine if the user referenced the object by name or UUID.  Can I take the object reference to be UUID if and only if it begins with an underscore?

Accepted answer


permanent link
David Lafreniere (4.6k7) | answered Oct 08 '20, 8:21 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

If you have access to the RTC plain-Java API, you can call com.ibm.team.repository.common.UUID.valueOf(userSuppliedValue), and if that call throws an IllegalArgumentException, then it was not a valid UUID (that's the main fool proof way).
(but yes, a UUID is 22 characters long and starts with an _  , but just keep in mind it's always possible for a crazy user to have a stream name start with an underscore and happen to also be 22 characters long)




Geoff Alexander selected this answer as the correct answer

Your answer


Register or to post your answer.