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
>Solution :
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> token) {
UUID key = UUID.fromString(uuidAsString);
return token.containsKey(key);
}
Pay attention that fromString can throws IllegalArgumentException if name does not conform to the string representation of UUID