Get key of type UUID and compare to string value

I have a HashMap of type UUID and token. The UUID is the key. I want to get the keys as a String and compare it to another String. Here my Hashmap :

private final Map<UUID,Token> token = new HashMap<>();

and then I want e.g

token.containsKey(string) = true

but it wont work like this.

And I want to extract the key value (UUID) and compare it to a string. So it should compare these two. I have tried for loops and with containsKey() but it did not work. Has anyone a solution to this?

Thanks in regard


If I Understand, in a given UUID as a key, you want from it's String value get it's Token Value?

So for example:

public boolean isContains(String uuidAsString, Map<UUID, Token> tokenMap) {
    UUID key = UUID.fromString(uuidAsString);  // Parse input string as a UUID object.
    return tokenMap.containsKey(key);  // Look for that UUID object among the map’s keys.
}

Pay attention that fromString can throws IllegalArgumentException if name does not conform to the string representation of UUID